本文整理汇总了C#中String.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# String.GetType方法的具体用法?C# String.GetType怎么用?C# String.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类String
的用法示例。
在下文中一共展示了String.GetType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ArrayIntro
private static void ArrayIntro() {
String[] sa = new String[1];
Array a1 = Array.CreateInstance(typeof(String), new Int32[] { 1 }, new Int32[] { 0 });
Array a2 = Array.CreateInstance(typeof(String), new Int32[] { 1 }, new Int32[] { 1 });
Console.WriteLine(sa.GetType().ToString());
Console.WriteLine(a1.GetType().ToString());
Console.WriteLine(a2.GetType().ToString());
}
示例2: Go
public static void Go() {
Array a;
// Create a 1-dim, 0-based array, with no elements in it
a = new String[0];
Console.WriteLine(a.GetType()); // System.String[]
// Create a 1-dim, 0-based array, with no elements in it
a = Array.CreateInstance(typeof(String), new Int32[] { 0 }, new Int32[] { 0 });
Console.WriteLine(a.GetType()); // System.String[]
// Create a 1-dim, 1-based array, with no elements in it
a = Array.CreateInstance(typeof(String), new Int32[] { 0 }, new Int32[] { 1 });
Console.WriteLine(a.GetType()); // System.String[*] <-- INTERESTING!
Console.WriteLine();
// Create a 2-dim, 0-based array, with no elements in it
a = new String[0, 0];
Console.WriteLine(a.GetType()); // System.String[,]
// Create a 2-dim, 0-based array, with no elements in it
a = Array.CreateInstance(typeof(String), new Int32[] { 0, 0 }, new Int32[] { 0, 0 });
Console.WriteLine(a.GetType()); // System.String[,]
// Create a 2-dim, 1-based array, with no elements in it
a = Array.CreateInstance(typeof(String), new Int32[] { 0, 0 }, new Int32[] { 1, 1 });
Console.WriteLine(a.GetType()); // System.String[,]
}