Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 533
JAN Avatar asked Oct 20 '15 22:10

JAN


Video Answer


1 Answers

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.

like image 162
w.b Avatar answered Oct 10 '22 10:10

w.b