Results 1 to 5 of 5

Thread: Value type V/s Reference Type in C #

  1. #1
    Join Date
    Apr 2008
    Posts
    240

    Value type V/s Reference Type in C #

    Hello my friends , have got some doubt in the object oriented programming language programming language concept , I d not mind if you explain in the context of any language , but most probably I will recommend if you can explain in the context of C# language , since I am using the .NET framework based programming language and the Microsoft Visual Studio for learning the programming language . Please help me if you have any kind of idea regarding the value type and reference type being used in the C# language . I am a bit confused in it as it seems everything same. I will be very grateful to you . Thank you in advance.

  2. #2
    Join Date
    May 2009
    Posts
    511

    Re: Value type V/s Reference Type in C #

    Well you can find out the following difference in the value type and the reference type :

    • Value types inherit from System.ValueType.
    • While Reference types inherit from System.Object. class
    • Value types is not able to derive a new type from an on hand value type, but they are capable of implementing an interfaces.
    • Reference types can inherit a new type from an existing reference type along with capable of implementing interfaces.
    • Modifying the value of one value type does not influence the value of one more value type.
    • Modifying the value of one reference type MAY modify the value of an additional reference type.
    • The nullable type (only in .NET 2.0) can be allocateed the value null.

  3. #3
    Join Date
    May 2009
    Posts
    637

    Re: Value type V/s Reference Type in C #

    I will say that using a value type reference has an edge over the reference type variables , the memory allocated to the value type variables are much more quickly allocated to the value type variable as they are stored in a stack so it and the reference are stored in the heap so they much more tile in getting assigned than that of value types , they same things happens when you are actually de- allocating freeing the memory , for example take the example of structs they are allocated as soon as they are created and then destroyed as soon as there scope is deleted .

  4. #4
    Join Date
    May 2009
    Posts
    543

    Re: Value type V/s Reference Type in C #

    • A identifier that is of type value directly holds a value. Allotting a variable of type value to one more variable of type value that creates a copy of that value.
    • A identifier of type reference, indicates to a place in memory where the definite object is enclosed. Allotting a variable of type reference to one more variable of type reference creates a copy that reference (it informs the new object where the position in memory is), but does not create a copy of the object.

  5. #5
    Join Date
    Apr 2009
    Posts
    488

    Re: Value type V/s Reference Type in C #

    One region probably to cause puzzlement for those coming from a Java or VB6 background is the difference between value types and reference types in C#. In particular, C# renders two types—class and struct, which are approximately the similar except that one is a reference type while the further is a value type. When we say that the value type mean it is stored in the stack and a variable storing the reference type is stored in the heap.

Similar Threads

  1. Convert reference types in value type and vice versa
    By Terawa in forum Software Development
    Replies: 3
    Last Post: 13-02-2011, 07:41 AM
  2. Replies: 4
    Last Post: 02-01-2011, 12:25 AM
  3. Replies: 1
    Last Post: 16-08-2010, 05:25 PM
  4. Replies: 1
    Last Post: 16-08-2010, 04:44 PM
  5. ACPI: expecting a [Reference] package element, found type 0
    By MobiNuX in forum Operating Systems
    Replies: 3
    Last Post: 24-09-2009, 03:43 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,254,776.43719 seconds with 17 queries