1

MSDN 文档显示了以下示例,可以完全按照我的意愿进行操作。但是,但是,但是......为了获得各种 UITestControls(例如“WpfWindow”、“WpfButton”等),一个字符串中的分隔项是什么?

=================================== MSDN代码============== ======================

private static string instanceSpec = "System.EventArgs;System.Random;" +
    "System.Exception;System.Object;System.Version";

public static void Main()
{
    string[] instances = instanceSpec.Split(';');
    Array instlist = Array.CreateInstance(typeof(object), instances.Length);
    object item;
    for (int i = 0; i < instances.Length; i++)
    {
        // create the object from the specification string
        Console.WriteLine("Creating instance of: {0}", instances[i]);
        item = Activator.CreateInstance(Type.GetType(instances[i]));
        instlist.SetValue(item, i);
    }
    Console.WriteLine("\nObjects and their default values:\n");
    foreach (object o in instlist)
    {
        Console.WriteLine("Type:     {0}\nValue:    {1}\nHashCode: {2}\n",
            o.GetType().FullName, o.ToString(), o.GetHashCode());
    }
4

0 回答 0