Please help us settle the: controversy? Is everything in c# an object, I thought that was the case as everything in Visual Studio at least appears as a struct? Please post a reference so that it doesn't become "modern jackass" (this American life).
Note that this question reffers to C# not necessarily .NET and how it handles the data under the hood (obviously it's all 1's and 0's.)
Here are the comments to "everything is an object":
- Eh, no, it's not. – Binary Worrier
- I'd like an example... – scotty2012
- isn't everything derived from the base type Object? – rizzle
- Most things are objects... – Omar Kooheji
- Value types, ints, doubles, object references (not the objects them selves) etc aren't objects. They can be "boxed" to look like objects (e.g. i.ToString()) but really they're primitive types. Change the entry to "NEARLY everthing is an object" and I'll remove the downvote – Binary Worrier
- I appreciate the clarification. I think the lowest level that you can interact with, say an int, in c# is as a struct, which isn't an object? - http://msdn.microsoft.com/en-us/library/ms173109.aspx – rizzle
- Doesn't Int32 inherit from ValueType which inherits from Object? If so, despite the behavior, an int is an object. – Chris Farmer
- No, the boxed type for int inherits from ValueType, which inherits from Object. They're not objects in the traditional sense because a) an int isn't a reference to an int, IT IS the int. b) ints aren't garbage collected. If you declare an Int32, then that int is 4 bytes on the stack, end of story – Binary Worrier
EDIT CLARIFICATION: Definition of object: "Object" as a inheritor of class System.Object vs. "object" as an instance of a type vs. "object" as a reference type."