Interview Questions

Is string a value type or a reference type?

ASP.NET and .NET WEB Questions and Answers


(Continued from previous question...)

Is string a value type or a reference type?

Answer1:
String is Reference Type.
Value type - bool, byte, chat, decimal, double, enum , float, int, long, sbyte, short,strut, uint, ulong, ushort
Value types are stored in the Stack
Reference type - class, delegate, interface, object, string
Reference types are stored in the Heap


Answer2:
Yes String is reference type. C# gives two types of variable reference and value type. string and object are reference type.

(Continued on next question...)

Other Interview Questions