“根据定义,所有的值类型都必须从System.ValueType派生,所有的枚举都从System.Enum抽象类型中派生,后者又从System.ValueType派生的” -------摘自《CLR VIA C#》;
可以通过查找MSDN
测试代码:
class Program
{static void Main(string[] args)
{ Program p = new Program();int m = 1;
Console.WriteLine("int m=1"); p.function(m); double n = 2.44; Console.WriteLine("double n = 2.44"); p.function(n); string x = "dasdas"; Console.WriteLine("string x"); p.function(x); M mm = new M(); Console.WriteLine("M为结构体"); p.function(mm); Console.WriteLine("Program p "); p.function(p); Console.ReadLine(); }public void function(Object o)
{if (o.GetType().IsValueType)
Console.WriteLine( "类型:" + o + "为值类型"); else Console.WriteLine( "类型:" +o + "为引用类型"); }}
public struct M { int x; int y; }输出结果: