2
Answers

passing method to instance with out creating objeect

harry code

harry code

7y
516
1
hi,
my code gies like this.
 
 
class Testprogram
{
public void callmethod()
{
Console.WriteLine("hello wrotld"); 
}
static void Main()
{
Testprogram t= new Testprogram();
t.callmethod();
Console.ReadLine();
}
}
 
 
 
now i want to execute with the below code instead of creating object.
 
 
static void Main()
{
 new Testprogram(callmethod());
Console.ReadLine();
}
 
Is it possible to do so?.
 
Thank you. 
Answers (2)