Use 'is' for int value type : Integer Family « Data Type « C# / CSharp Tutorial
- C# / CSharp Tutorial
- Data Type
- Integer Family
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