I am learning about C# refs right now.
Is it safe to assume that all variables that are assigned with a new are references and not values?
Example:
SomeType variable = new SomeType()
I am learning about C# refs right now.
Is it safe to assume that all variables that are assigned with a new are references and not values?
Example:
SomeType variable = new SomeType()
No, value types are not references.
But with any other non-valuetype type and 'ref/out' parameter, they are references.
No. In C# structs are also instantiated using new(), but are treated as values.
Looks like you are confusing references with objects. If that is the case than yes types that are created with the new keyword are objects. With the exception of structures which are treated as values.
Not necessarily. As you learn more about C# you'll find you have classes, which are reference types, and structs, which are value types. Both of them are instantiated through the use of the 'new' keyword, but instances of structs are not references.
No:
For example, System.Drawing.Point
is a struct
not a class
:
Point point = new Point(1, 1); //point is a value, not a reference
C# has two types of objects - Reference Types (defined with a class keyword) and Value Types (defined with a struct keyword).
Pick up a good book on C# for more details.. Its an important concept.