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
How do I create a single-file assembly?
What is meant by generics in c#?
Can a loop recorder detect a heart attack?
Why we use get set property in c#?
Can a string be null c#?
What is int64 in c#?
How to use session under class file of APP_Code folder?
How to rotate an Image in C#?
What is inline function in c#?
How do I enforce const correctness in c#?
What is dynamic in c#?
Should I make my destructor virtual?
What is different between Static Constructor and Private Constructor?
Is multiple inheritance possible in c#?
What is private variable?