Mega Code Archive

 
Categories / C# Tutorial / Data Type
 

Use is for int value type

using System; public class MainClass {     static void Main() {         int j = 123;         object boxed = j;         object obj = new Object();         Console.WriteLine( "boxed {0} int", boxed is int ? "is" : "isnot" );         Console.WriteLine( "obj {0} int", obj is int ? "is" : "isnot" );         Console.WriteLine( "boxed {0} System.ValueType", boxed is ValueType ? "is" : "isnot" );     } } boxed is int obj isnot int boxed is System.ValueType