Why running this C# code shows error on F1();
in Main?
namespace Project1
{
public partial class Program1
{
private void F1()
{
Console.WriteLine("F2");
}
private void F2()
{
Console.WriteLine("F1");
}
static void Main(string[] args)
{
F1();
}
}
}
This is a console application. It works if I define an object of class Program1
.
But when I try this on a Windows Form Application, I can put F1();
in a button_click
event and it runs without error without defining an object of Class Form1
?