I’ve got the following in a console application:
class Program {
static void Main(string[] args) {
Program myProgram = new Program();
if (myProgram.foo() == true) {
myProgram.bar();
}
}
public bool foo() {
//check some stuff
}
public void bar() {
//do some stuff
}
}
Is creating an instance of Program in the Program’s Main method bad practise and prone to problems?
Short answer: yes. Just make your two methods
staticand then you won’t need to create an instance.