SoFunction
Updated on 2025-03-08

Example analysis of simple unboxing operation usage in C#

This article describes the simple usage of unboxing operations in C#. Share it for your reference. The details are as follows:

Unboxing in C# is a process that allows references to be processed as value types. The following code implements the conversion of object to int type

using System;
class ConversionSample
{
  static void Main()
  {
    Object obj = 123;
    int num1 = (int)obj;
    (());
    (());
  }
}

I hope this article will be helpful to everyone's C# programming.