Search code examples
c#.netintprimitivevalue-type

Is int (Int32) considered an object in .NET or a primitive (not int?)?


Is int (aka Int32) an object , or a primitive in .NET (I'm not asking regarding int?)?

I hit F12 on the saved word int and got :

public struct Int32 : IComparable, IFormattable, IConvertible, IComparable<int>, IEquatable<int>

{ ... }

It doesn't inherit from Object , does it mean that int is a primitive ?


Solution

  • Everything in C# inherits from object, including int.

    From msdn:

    Int32 is an immutable value type that represents signed integers

    and

    Both reference and value types are derived from the ultimate base class Object.