Int,bool,decimal, etc. as a value type
List,stream, etc. as a reference type
When you set a value type variable equal to another variable with an equal sign, the copy is completed, and then the two variables have no effect on each other;
When you use the equals sign for a reference, the two references point to the same object
For value types and reference types, variable declarations and replication are the same.
int howmany = 25;
bool Scary = true;
List<double> temperatures = new list<double> ();
int and bool are value types, and list is reference type, and they all initialize in the same way
But once the assignment starts, it's different.
Value type assignment:
int fifteenmore = Howmany;
Fifteenmore + = 15;
Console.WriteLine ("Howmany has {0},fifteenmore have {1}", Howmany,fifteenmore);
Output: Howmany has 25,fifteenmore have 40
Reference type Assignment:
Temperatures. ADD (56.5D);
Temperatures. ADD (27.4D);
List<double> differentlist = temperatures;
Differentlist.add (62.9D);
Cosole.writeline ("Temperature has {0},differentlist have {1}", temperature. Count (), Differentlist.count ());
Output: Temperatures has 3,differentlist have 3
Similarities and differences between C # value types and reference types