In c # all data types are objects?

0

This is a topic that does not end up being clear, looking at official sites, forums and other pages. So-called "primitive data" in c # if so, are they all objects?

An example is the int internally is a struct but according to the documentation the struct is an implicit implementation of the class System.ValueType then in believing.

    
asked by crack81 02.08.2016 в 07:38
source

1 answer

2

There are two categories

Value types (value type)

and the

Reference types

It is clear that to derive something else everything is objects, perhaps the confusion you have is that the types by value can also be instantiated. This is because when you use int it's actually an alias of System.Int32 .

All are objects, but do not behave in the same way, when you assign a value to a variable int when passing it to another copy its content, instead a type by reference will be a pointer to the address in memory.

Changing the value assigned to an int will not affect the other variables that you have assigned with it, whereas if you change a type by reference if it affects them.

    
answered by 02.08.2016 / 12:43
source