Mega Code Archive

 
Categories / C# Book / 01 Language Basics
 

0177 Generic type and ref, out

Generic type can have ref and out modifier. using System; class Test { static void print<T>(ref T t) { Console.WriteLine(t); } static void Main() { string str = "asdf"; print(ref str); } } The output: asdf