C# error: “An object reference is required for the non-static field, method, or property”

The Main method is Static. You can not invoke a non-static method from a static method.


is not a static method. Either you have to create an instance of Program

Program p = new Program();

or make

GetRandomBits() static.

Leave a Comment