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
What is the use of return in c#?
Is int a class in c#?
What are data types in C#?
What is remote data?
Why singleton is sealed?
What is the difference between a private assembly and a shared assembly?
How do you declare an interface in c#?
Can I do things in il that I can't do in c#?
What is type system in c#?
What do you mean by the delegate in c#?
What is the difference between ref and out in c#?
How to find Percentage, name ,College from a resume or document ? How to export these values to other page in C#?
What are the 3 different types of arrays?
What is different between Implicit conversion and Explicit conversion in C#?
For read-only operation which property you have to designated?