C# Programming - Datatypes - Discussion

Discussion :: Datatypes - General Questions (Q.No.16)

16. 

Which of the following statements are correct about datatypes in C#.NET?

  1. Every datatype is either a value type or a reference type.
  2. Value types are always created on the heap.
  3. Reference types are always created on the stack.
  4. Mapping of every value type to a type in Common Type System facilitates Interoperability in C#.NET.
  5. Every reference type gets mapped to a type in Common Type System.

[A]. 1, 3
[B]. 2, 5
[C]. 1, 4
[D]. 3, 4

Answer: Option C

Explanation:

No answer description available for this question.

Gopesh said: (Jun 27, 2012)  
DataType is either a value type or a reference type, other than that no other type is available.

Value types are always created on the Stack.

Reference types are always created on the Heap.

Mapping of every value type to a type in Common Type System facilitates Interoperability in C#. NET so that MSIL be prepared that is same for all language.

Eliashdez said: (Feb 8, 2013)  
Gopesh, Value Types can be created also in the Heap. Make a Google search of: The Truth About Value Types by Eric Lippert. Amazing reading!

Sweta said: (Sep 25, 2013)  
Value types are always created on the Stack.

Reference types are always created on the Heap.

So the answer cannot have option 2, 3 so left is c.

This type of trail is when you know few details not all.

Marian said: (Oct 11, 2013)  
Sometimes, value types are created on the Heap.

Example:

class MyClass
{
int classVar;
}

The instance of this class will be created on the heap including variable classVar.

Vishal said: (May 22, 2014)  
Value type is created on stack and reference type is created on heap.

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.