We can use default
keyword to get the default value for generic type parameter.
using System;
class Test
{
static void print<T>(T t)
{
Console.WriteLine(default(T));
}
static void Main()
{
int i = 5;
print(i);
}
}
The output:
0
java2s.com | Contact Us | Privacy Policy |
Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
All other trademarks are property of their respective owners. |