I want to convert a decimal number (int
) to a binary number and print it out.
My code in C# is this:
int t1 = 2;
public string test = Convert.ToString(t1, 2);
I get the error:
A field initializer cannot reference the nonstatic field, method, or property 'field'
I cannot find a solution for this :/
I found the solution: you have to declare t1 as static. static int t1 works!