find out whether type is value or reference type
Published: 20. October 2011 | Updated: 26. October 2011License: Microsoft Public License (MS-PL)
Categories: Framework » Types
Tags: Basics C#
int number = 123456; Type type = number.GetType(); Console.WriteLine(type.IsValueType ? "Value type" : "Reference type"); string text = "test"; type = text.GetType(); Console.WriteLine(type.IsValueType ? "Value type" : "Reference type");Console Output:
Value type
Reference type
Reference type
| Send us feedback about this snippet » |





