I have a generic class Program with static method as below:
class Program
{
public static void Main()
{
Console.WriteLine("HI from program");
Console.ReadLine();
}
}
When I try to access the static Main method inside a generic class Program1 as below:
class Program1<T> : Program where T : Program
{
public static void check()
{
T.Main();
}
}
I get the error :
'T' is a 'type parameter', which is not valid in the given context
However if I use
public static void check()
{
Program.Main();
}
Everything runs fine. Can you please explain the mistake that I might be committing?