C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Value Type and Reference Type


Posted Date: 20 Jun 2008    Resource Type: Definitions    Category: General

Posted By: Ratheesh       Member Level: Gold
Rating:     Points: 10



Value types are stored directly on the stack, either within an array or within another type. When the location containing a value type instance is destroyed, the value type instance is also destroyed. Value types are always accessed directly; it is not possible to create a reference to a value type. Prohibiting such a reference makes it impossible to refer to a value class instance that has been destroyed. A variable of a value type always contains a value of that type. Unlike reference types, the value of a value type cannot be a null reference, nor can it reference an object of a more derived type. Assignment to a variable of a value type creates a copy of the value being assigned.

Reference types are stored on the run-time heap; they may only be accessed through a reference to that storage. This allows the garbage collector to track outstanding references to a particular instance and free the instance when no references remain. A variable of reference type always contains a reference to a value of that type or a null reference. A null reference refers to nothing; it is invalid to do anything with a null reference except assign it. Assignment to a variable of a reference type creates a copy of the reference, not a copy of the value being referenced.




Responses

Author: Bunty    25 Jun 2008Member Level: Diamond   Points : 2
Hi,
Nice defination on Value type and Reference type.

You clearly explain where value type is stored and reference
type.

You can include more on it like boxing and un-boxing.

Also you can include examples like object,array are reference type in .Net like that.

By the way Keep Posting.

Thanks and Regards
S.S.Bajoria


Author: Rajeev Kumar Dubey    30 Jun 2008Member Level: Silver   Points : 0
thanks good definition


Author: Sriram    05 Oct 2008Member Level: Gold   Points : 2
Value Types: The Actual value of the Variable Stored on Stack is called Value Types.
Stack is a small memory area.Value Types access Directly to the Data.
Value types Examples:
String
int
long
short
reference Type:
The Value of the Variable stored on heap is called Reference Type.The Value of the Variable called on Head.
Examples:
class
delegates
Events
enum.

thanks
SriramRamaswamy


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: What is a Trigger?
Previous Resource: The BREAK and CONTINUE Statements in SQL Server
Return to Discussion Resource Index
Post New Resource
Category: General


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

doors in nj

Contact Us    Privacy Policy    Terms Of Use