Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/266.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在windows上获取ID_C# - Fatal编程技术网

C# 在windows上获取ID

C# 在windows上获取ID,c#,C#,我有一个我无法解决的错误,甚至连搜索互联网都不行。 我的代码: 我不知道是什么错误。如果你能帮我,我不太懂这门语言。 非常感谢您的帮助。试试换衣服 using (PropertyDataCollection.PropertyDataEnumerator enumerator2 = ManagementClass.Properties.GetEnumerator()) { while (enumerator2.MoveNext()) { if (enumerator

我有一个我无法解决的错误,甚至连搜索互联网都不行。 我的代码:

我不知道是什么错误。如果你能帮我,我不太懂这门语言。 非常感谢您的帮助。

试试换衣服

using (PropertyDataCollection.PropertyDataEnumerator enumerator2 = ManagementClass.Properties.GetEnumerator())
{
    while (enumerator2.MoveNext())
    {
        if (enumerator2.Current.Type == CimType.String)
        {
            flag = true;
        }
    }
}


首先,必须删除“using”,因为GetEnumerator()不返回一次性对象;其次,使用“managementClass.Properties.GetEnumerator()”而不是“managementClass.Properties.GetEnumerator()”

错误是什么?你想干什么?你能把一个文件放在一起让其他人尝试编译吗?请发布错误。最好是整个堆栈跟踪。什么是错误?你能帮我收集电脑的id吗?。以一个程序的代码为例,但它不能让我获得所有的id,并且在程序中,它引导我是的。
using (PropertyDataCollection.PropertyDataEnumerator enumerator2 = ManagementClass.Properties.GetEnumerator())
// using (ManagementObjectCollection.ManagementObjectEnumerator enumerator2 = disks.GetEnumerator())
using (PropertyDataCollection.PropertyDataEnumerator enumerator2 = ManagementClass.Properties.GetEnumerator())
{
    while (enumerator2.MoveNext())
    {
        if (enumerator2.Current.Type == CimType.String)
        {
            flag = true;
        }
    }
}
PropertyDataCollection.PropertyDataEnumerator enumerator2 = managementClass.Properties.GetEnumerator();
while (enumerator2.MoveNext())
{
    if (enumerator2.Current.Type == CimType.String)
    {
        flag = true;
    }
}