Search this blog

You can search for all the topics in our blog using our google custom search now.

Search the blog

Loading

Monday, August 2, 2010

Value Types V/S Reference Types




Value Types and Reference Types:

  1. Value types are defined from System.ValueType  while the reference types are derived from System.Object.
  2. The stack holds the value type variables along with return addresses.
  3. The heap holds the reference type variables value.


Copying Value Types Variables:

  1. If you copy one value type variable from another, a direct copy of variable value is made.







  1. If you are curious how is it created on stack, then this is how it is looks on stack:



  1. So now when we copy the value of a to b by using the following statement:






4. Value of a is directly copied to b.





Copying Reference Type Variables:
  1. Lets create a variable of type reference. String is a built-in reference type, we will create an object of string and assign some value to it as follows:




Regards
Sameer Shaik

Tags: Microsoft MCTS exam, Learn, Tutorials, Free C#, Free Videos, Microsoft Dot Net Jobs,Microsoft Dot Net Jobs Interview, Free Training and Preparation, Jobs MCTS specialization, visual studio.net, study guide, sample questions, Exam Prep, Exam Practice Test




No comments:

Post a Comment