Hello guys, I have a question regarding this code. I'm a beginner and enjoy learning C#. But then I'm on the topic now called Array which is quite difficult and I need your help. I would like to understand the code.
What I don't understand here is what does the part 1, 2, 3, 4 and 5 here mean?
I don't understand what is the function of "const" and "byte" here?
I would appreciate your explanation?
Thanks & regards;-)
1)
const byte numbers = 5;
byte[] myNumbers = new byte[numbers];
byte additionalNumbers;
Random coincidenceNumbers = new Random();
2)
string yourPassword;
Console.WriteLine("Please enter your password:");
yourPassword = Console.ReadLine();
if (yourPassword != "helloWorld")
{
Console.WriteLine("\nWrong password\n");
return;
}
else
{
Console.WriteLine();
Console.WriteLine("Welcome to my world!");
for (int i=0; i < myNumbers.Length; ++i)
{
myNumbers[i]=(byte)(coincidenceNumbers.Next(1,50));
}
}
3)
additionalNumbers=(byte) (coincidenceNumbers.Next(1,50));
4)
Array.Sort(myNumbers);
Console.WriteLine("\nThe Number is:\n");
5)
foreach (byte elem in myNumbers)
{
Console.WriteLine("\t" + elem);
Console.WriteLine();
Console.WriteLine("Additional Number is: " + additionalNumbers);
}