使用 new 关键字创建数组的实例。new 运算符用于创建对象或实例化对象。在此示例中,使用 new 为类创建了一个对象。以下是一个示例。Calculate c = new Calculate();您还可以使用 new 关键字创建数组的实例。double[] points = new double[10];new 关键字还用于创建集合的对象。SortedList sl = new SortedList(); // SortedList List myList = new List() // List让我们看一个示例。示例 在线演示using System; class Program { static void Main() ... 阅读更多
Typeof()该类型采用 Type 并返回参数的 Type。例如:对于以下内容,System.Byte-typeof(byte)以下是一个示例-示例 在线演示using System; class Program { static void Main() { Console.WriteLine(typeof(int)); Console.WriteLine(typeof(byte)); } }输出System.Int32 System.ByteGetType()C# 中数组类的 GetType() 方法获取当前实例的 Type。要获取类型。Type tp = value.GetType();在下面的示例中,我们使用 type 检查 int 值。if (tp.Equals(typeof(int))) Console.WriteLine("{0} is an integer data type.", value)以下是 C# 中 GetType() 方法的用法。示例 在线演示using System; class Program { ... 阅读更多