Is string reference type / value type?
Answer Posted / n.
There is no magic.... You can test all the types:
using System;
using System.Collections.Generic;
using System.Text;
namespace List_Value_Types
{
class Program
{
static void Main(string[] args)
{
SByte a = 0;
Byte b = 0;
Int16 c = 0;
Int32 d = 0;
Int64 e = 0;
string s = "";
Exception ex = new Exception();
object[] types = { a, b, c, d, e, s, ex};
foreach (object o in types)
{
string type = "";
if (o.GetType().IsValueType)
type = "Value type";
else
type = "Reference type";
Console.WriteLine("{0}: {1}", o.GetType(),
type);
}
Console.ReadKey();
}
}
}
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
Is string a data type in c#?
What is the syntax for calling an overloaded constructor within a constructor?
What is Assembly. and Describe type of assembly. why most developer happy with private assembly.
what is the equivalent to regsvr32 and regsvr32 /u a file in .net development?
Can we declare class as protected?
What is the use of ispostback in c#?
What is windows forms in c#?
What is CLR and its application.?
What are the value types in c#?
what is the difference between .dll and .exe
what is the purpose of using statement in c#
What is the difference between console application and windows application?
What are the benefits of using generics?
Write a sample code to write the contents to text file in c#?
Can private virtual methods be overridden in c#.net?