.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Interview Question >> C# >> Post New Question Subscribe to Interview Questions

Explain Value type and reference type?

Posted By :Gowthammanju     Posted Date :July 31, 2011    Points :40   Category :C# 
Value Type
Variables of value types directly contain their data.
Value types store in stack.
Reference Type
Variables of reference types store references to their data
Reference types store in Heap Memory.



that have an odd index value.

$("li:first"): Selects the first
  • element.

    $("li:last"): Selects the last
  • element.

    $("li:visible"): Selects all elements matched by
  • that are visible.

    $("li:hidden"): Selects all elements matched by
  • that are hidden.

    $(":radio"): Selects all radio buttons in the form.

    $(":checked"): Selects all checked boxex in the form.

    $(":input"): Selects only form elements (input, select, textarea, button).

    $(":text"): Selects only text elements (input[type=text]).

    $("li:eq(2)"): Selects the third
  • element

    $("li:eq(4)"): Selects the fifth
  • element

    $("li:lt(2)"): Selects all elements matched by
  • element before the third one; in other words, the first two
  • elements.

    $("p:lt(3)"): selects all elements matched by

    elements before the fourth one; in other words the first three

    elements.

    $("li:gt(1)"): Selects all elements matched by

  • after the second one.

    $("p:gt(2)"): Selects all elements matched by

    after the third one.

    $("div/p"): Selects all elements matched by

    that are children of an element matched by

    .

    $("div//code"): Selects all elements matched by that are descendants of an element matched by
  • that are the first child of their parent.

    $("li:last-child"): Selects all elements matched by
  • that are the last child of their parent.

    $(":parent"): Selects all elements that are the parent of another element, including text.

    $("li:contains(second)"): Selects all elements matched by
  • that contain the text second.

    You can use all the above selectors with any HTML/XML element in generic way. For example if selector $("li:first") works for
  • element then $("p:first") would also work for

    element. (More...)

    Difference between type constructor and instance constructor? What is static constructor, when it will be fired? And what is its use?

      
    (Class constructor method is also known as type constructor or type initializer)
    Instance constructor is executed when a new instance of type is created and the class constructor is executed after the type is loaded and before any one of the type members is accessed. (It will get executed only 1st time, when we call any static methods/fields in the same class.) Class constructors are used for static field initialization. Only one class constructor per type is permitted, and it cannot use the vararg (variable argument) calling convention. (More...)

  • You can also find related Interview Question to Explain Value type and reference type?  below: 

    How do I call a member method and pass a primitive type (Value Type) by reference?

      
    Use the ref keyword when declaring the parameter of the method, for example:

    public bool GetValue( ref int returnValue );

    This will pass the numeric by reference.You can modify the value of returnValue within the body of GetValue and it will persist when the method call returns. (More...)

    Value type & reference types difference? Example from .NET. Integer & struct are value types or reference types in .NET?

      
    Most programming languages provide builtin data types, such as integers and floatingpointnumbers, that are copied when they are passed as arguments (that is, they are passed by value). In the .NET Framework, these are called value types. The runtime

    supports two kinds of value types:
    · Builtin
    value types
    The .NET Framework defines builtin
    value types, such as System.Int32 and
    System.Boolean, which correspond and are identical to primitive data types
    used by programming languages.
    · Userdefined
    value types
    Your language will provide ways to define your own value types, which derive from System.ValueType. If you want to define a type representing a value that is small, such as a complex number (using two floatingpoint numbers),
    you might choose to define it as a value type because you can pass the value type efficiently by value. If the type you are defining would be more efficiently passed by reference, you should define it as a class instead.

    Variables of reference types, referred to as objects, store references to the actual data. This following are the reference types:
    · class
    · interface
    · delegate
    This following are the builtin
    reference types:
    · object (More...)

    convert a value-type to a reference type is known as?

      
    Boxing.

    Boxing is the terminology used in .NET Framework to convert Value type to reference type (More...)

    convert a Reference Type to a Value type is known as?

      
    UnBoxing.

    UnBoxing is the terminology used in .NET Framework to convert Reference Type to a Value type (More...)

    what is the difference between value type and reference type?

      
    Value type is stored in stack.
    Reference type stored in heap. (More...)

    Is array reference type / value type?

      
    Array is a reference type and it is stored in Heap memory!

    Reference types are:
    object
    class
    delegate
    interface
    array
    string

    (More...)

    Is string reference type / value type?

      
    string is reference type
    because String is immutable objects..........
    means does not change the values(string)....... (More...)

    What is Reference type and value type ?

      
    Reference Type:
    Reference types are allocated on the managed CLR heap, just like object types.
    A data type that is stored as a reference to the value's location. The value of a reference type is the location of the sequence of bits
    that represent the type's data. Reference types can be self-describing types, pointer types, or interface types

    Value Type:
    Value types are allocated on the stack just like primitive types in VBScript, VB6 and C/C++. Value types are not instantiated using new go out of scope when the function they are defined within returns.
    Value types in the CLR are defined as types that derive from system.valueType.

    A data type that fully describes a value by specifying the sequence of bits that constitutes the value's representation. Type information for a value type instance is not stored with the instance at run time, but it is available in metadata. Value type instances can be treated as objects using boxing.
    (More...)

    How do you call a Member method and pass a value Type by reference?

      
    use the "ref" keyword when declaring a Parameter of the Method
    Ex:
    public bool GetValue(ref int returnvalue);
    (More...)

    An Interface is a Value type or reference Type?

      
    Interface is a Value type as well as Reference type (More...)

    How do you call a Member method and pass a value Type by reference?

      
    use the "ref" keyword when declaring a Parameter of the Method (More...)

    Explain different type of useful selectors in jQuery.

      
    Below is the list of different types of useful selectors in jQuery

    $('*'): This selector selects all elements in the document.

    $("p > *"): This selector selects all elements that are children of a paragraph element.

    $("#specialID"): This selector function gets the element with id="specialID".

    $(".specialClass"): This selector gets all the elements that have the class of specialClass.

    $("li:not(.myclass)"): Selects all elements matched by
  • that do not have class="myclass".

    $("a#specialID.specialClass"): This selector matches links with an id of specialID and a class of specialClass.

    $("p a.specialClass"): This selector matches links with a class of specialClass declared within

    elements.

    $("ul li:first"): This selector gets only the first

  • element of the
  • Quick Links For Interview Questions Categories:
    ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
    Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
    Biztalk Patten/Practices .IIS WCF WPF WWF
    Networking Aptitude Others   All      

    Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

     
    Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

    So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.


    Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend