harry code

harry code

  • NA
  • 124
  • 22.8k

passing method to instance with out creating objeect

Feb 27 2018 1:30 AM
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)