mercredi 2 décembre 2020

İn C#, How can i use random command with variables [closed]

(First I Apologize for my english) I try making draw application with C#. You can use up to 10 values in the application. I create kisi1, kisi2,..., kisi10 variables. İn Example

Console.Write("Say the first person's name: ");
            string kisi1 = Console.ReadLine();

Thanks to this command, I get the first input from the user. I search to google "İn C#, How can i use random command with variables" But in Turkish Language. And I Find A Website And He Makes:

string isimler = { "Ahmet", "Ersan", "Faik", "Veli", "Burak", "Emine", "Canan", "Ayşe", "Simge" };
Random rastgelesayi = new Random();  // To make random number
int no = rastgelesayi.Next(0, isimler.Length); //Determine which element of the directory to print
Console.WriteLine(isimler[no]); 
Console.ReadKey();

I want try this and for this i make

string names = (kisi1, kisi2, kisi3, kisi4, kisi5, kisi6, kisi7, kisi8, kisi9, kisi10);

enter image description here

But I'm getting error I can't find any pages to "How Can I Use Random Command With Variables" And Now I Ask To You: How Can I Use Random Command With Variables




Aucun commentaire:

Enregistrer un commentaire