C# Programming - Strings - Discussion

Discussion :: Strings - General Questions (Q.No.11)


Which of the following statements about a String is correct?

[A]. A String is created on the stack.
[B]. Whether a String is created on the stack or the heap depends on the length of the String.
[C]. A String is a primitive.
[D]. A String can be created by using the statement String s1 = new String;
[E]. A String is created on the heap.

Answer: Option E


No answer description available for this question.

Varma_Life@Yahoo.Com said: (Dec 14, 2011)  
String is a value types, this are implicitly derived from System. ValueType. This class actually overrides the implementation in System. Object, the base class for all objects which is a reference type itself.

Value types are stored in the Stack.

Rajkumar said: (Dec 27, 2011)  
No wrong string is reference type its value store in heap.

Yakesh said: (Jul 17, 2012)  
Ya rajkumar is right, string, object are reference types. All remaining built in data types are value types.

Sami said: (Jan 4, 2014)  
String and object are reference types. While int, float, bool and all other are value types. Value types are stored on stack as well as heap. But strings are always stored on heap.

Gloops said: (Aug 4, 2014)  
@Varma_Life, please have a look at this :


Gloops said: (Aug 4, 2014)  
Really sure a String is not a primitive ?

Subhajit said: (Apr 5, 2015)  
String is always created in string buffer. So no stack, no heap is required for string. String is primitive because primitive data type which are understandable by respected language compiler and string is one of that data type.

Sudarshan said: (Jul 4, 2015)  
String is reference type.

String s; where s is heap. So string is created on the heap.

Narasimha said: (Nov 4, 2015)  
String is always reference type so it can stored in heap memory.

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.