Unbox of an object to an int in CSharp

Description

The following code shows how to unbox of an object to an int.

Example


using System;//  www.  ja v a  2  s.co m

class MainClass {

    public static void Main() {
        object myObject = 3;
        int myInt3 = (int)myObject;  // myObject is unboxed
        Console.WriteLine("myInt3 = " + myInt3);


    }

}

The code above generates the following result.





















Home »
  C# Tutorial »
    Data Types »




C# Data Types
Bool
Byte
Char
Decimal
Double
Float
Integer
Long
Short
String
C# Array
Array Example
Byte Array
C# Standard Data Type Format
BigInteger
Complex
Currency
DateTime
DateTimeOffset
DateTime Format Parse Convert
TimeSpan
TimeZone
Enum
Null
tuple
var