I agree with the other commentors- what’s really missing here is an understanding of what the static keyword means and what it means to instantiate objects.
The specific issue here is that your Program
class’s fields requires an instance before they can be accessed (Program
and it’s fields are not static) while your Main
method is static
.
In other words either:
- Change
Program
and it’s fields to static:static class Program
-
Instantiate
Program
inLoadSettings
before using it:static void LoadSettings() { //... Program p = new Program(); p.txtUserName = vals[0]; //... }
1
solved Console App error An object reference is required for the non-static field, method, or property