I understand the object reference is required for the non-static field has been asked many times before but reading them, I just didn't understand and I'm just stuck on this code, where the purpose is to generate a new random color each time it is called in a while loop.
I try to call it into my main function but it won't let me, and changing private to static void creates about 5x the issues. Yes I am new, and yes I didn't understand the other answers one bit. Sorry!
Here is all the code: (I know it's terrible, just trying to get it working first)
using System;
using System.Drawing;
namespace Number_things
{
class Program
{
static void Main(string[] args)
{
int value;
Console.Write("Enter a value: ");
value = Convert.ToInt32(Console.ReadLine());
while (value < 696969697)
{
GetRandomColor();
for (int i = 1; i <= value; i++)
{
for (int j = 1; j <= i; j++)
{
Console.Write(i);
}
}
Console.ReadKey();
}
}
private static Random random = new Random();
private Color GetRandomColor()
{
return Color.FromArgb(
random.Next(0, 256),
random.Next(0, 256),
random.Next(0, 256));
}
}
}