lamont Posted November 6, 2014 Share Posted November 6, 2014 40 kişilik sınıf listesindeki isimlere rastgele sayı atamak istiyorum diye örnek buldum ama nedemek istedigini tam olarak anlamadım soruyu anlamadım bende aşagıdaki kodu oluşturdum ama ne kadar dogru bilmiyorum isimlere rasgele sayı atayacak ama atandıktan sonraki mantıgı çözemedim aşagıdaki kod buna uygunmu private void button1_Click(object sender, EventArgs e) { string [] sinif = { "Ali", "Ayşe", "Nermin", "Gamze", "Erhan", "Süleyman", "Cansu", "Elif" }; Random r = new Random(); listBox1.Items.Clear(); for (int i = 0; i < sinif.Length; i++) { listBox1.Items.Add( sinif[ r.Next(7)]); } } } } Quote Link to comment Share on other sites More sharing options...
Editor pairs Posted November 6, 2014 Editor Share Posted November 6, 2014 HashTable incele onunla yaparsın eğer karşılıklı değer atamak istiyorsan. Yani Ali = 1 Ayşe = 30 gibi Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.