This is one of the Interview Question asked in Siemens. Before going through the answer , think of a function of int return type, and you want a string and integer value from that function to return. How you achieve this??? Think !!!! make a Guess……
I guess some of you may come up with the answer. And for others you can check below :
using System; namespace MultiReturnDemo { class Program { static void Main(string[] args) { string Name ; int Age = MethodA(out Name); Console.WriteLine("String Value from Function : " + Name); Console.WriteLine("Integer Value from Function : " + Age); Console.ReadLine(); } /// <summary> /// Function returning Integer and String Values /// </summary> /// <param name="s"></param> /// <returns></returns> public static int MethodA(out string s) { int i = 28; s = "Seekyourcareer.in"; return i; } } }