前回の質問のURL
イメージ的には
lang
1using System; 2using System.Text; 3using System.Windows.Forms; 4 5namespace testviewer 6{ 7 public partial class Form1 : Form 8 { 9 public Form1() 10 { 11 InitializeComponent(); 12 } 13 14 private void Form1_Load(object sender, EventArgs e) 15 { 16 17 } 18 19 private void wordbox_TextChanged(object sender, System.EventArgs e) 20 { 21 throw new System.NotImplementedException(); 22 } 23 24 private void numbarbox_KeyDown(object sender, KeyEventArgs e) 25 { 26 27 if (e.KeyCode == System.Windows.Forms.Keys.Enter) 28 { 29 30 //パスワードに使用する文字 31 private static readonly string passwordChars = "0123456789abcdefghijklmnopqrstuvwxyz"; 32 33 public string GeneratePassword(int length) 34 { 35 StringBuilder sb = new StringBuilder(length); 36 Random r = new Random(); 37 38 for (int i = 0; i < length; i++) 39 { 40 //文字の位置をランダムに選択 41 int pos = r.Next(passwordChars.Length); 42 //選択された位置の文字を取得 43 char c = passwordChars[pos]; 44 //パスワードに追加 45 sb.Append(c); 46 } 47 48 return sb.ToString(); 49 } 50 51 } 52 } 53 54 } 55}
のようにしたいのですがうまく行きません理由はわかっているのですがそれも不確かな状態です
どう助けてください><
回答2件
あなたの回答
tips
プレビュー