Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I understand what an object is (basically a concrete entity of something or someone). However just to confirm my understanding on the matter, are my bottom assumptions of what can be considered an object correct?

Either a instance or literal value or Value type is considered an object

//instance of user-defined struct type
      new Dog()

      //literal value of pre-defined struct type Int32
      29

Either an instance or literal value of Reference type is considered an object

//instance of a user-defined class type
      new Person()

      //literal value of pred-defined class type String
      "John"


According to the following Mircosoft documentation: https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/objects

A class or struct definition is like a blueprint that specifies what the type can do. An object is basically a block of memory that has been allocated and configured according to the blueprint.

Question: Thus, if an instance or literal value (of value type or reference type) is bassed off a blueprint (being a class or struct) then is anything that is an instance or literal value of struct type or class type considered an object?

What I have tried:

I would just like to verify whether my assumption is correct or incorrect. Thanks.
Posted
Updated 7-May-21 13:58pm
v2

Microsoft itself has confused .NET/C# programmers with lack of consistent explanations for Objects, and, clear distinctions between Objects and instances of Objects ...

1) Object in an abstract sense as found in the discourse around OOP as programming model, philosophy, a field in Computer Science

2) At times, MS has implied that C# is an OOP language ... I disagree:

2a) SmallTalk was/is an example of a true object-oriented language: everything is an object.

2b) C# has Value Types that are directly stored on the stack: they are primitives whose value is contained in their memory location. imho, these are not objects in the way Classes, Properties, are.

2c) depending on how you view multiple inheritance, C# either does not have this facility, or has a very limited implementation of it (via Interfaces),

A C# Class is the archetypal, mutable, reference Type: imho, the best metaphor is Class is to instance as blueprint is the whatever you construct from the blueprint.

You would not conclude that because you modified the house that the blueprint for the house had simultaneously changed ... and, vice-versa :)

These generalizations are simplified: the allocation and managements of String, and Struct, Enum, etc., are more complex. Making Classes Abstract, or Static, is another "dimension."

Further thoughts and links here: [^]
 
Share this answer
 
v3
You and Jake Sampson managed to post the exact same question: Is assumption concerning what is an object correct? C#[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900