Tuesday, November 24, 2009

A method which can return multiple datatypes in C#

Simple solution to achive this.




private void button1_Click(object sender, EventArgs e)

{




String test = TestFunction("Mahesh Bagul.");




Console.WriteLine(test);




int val = TestFunction(10);




Console.WriteLine(val);

}







private T TestFunction<T>(T val)

{




return val;


//For a while I just return same value.

}

No comments:

Post a Comment