相关疑难解决方法(0)

循环遍历对象并获取属性

我有一个方法返回操作系统属性列表.我想循环遍历属性并对每个属性进行一些处理.所有属性都是字符串

我如何循环对象

C#

// test1 and test2 so you can see a simple example of the properties - although these are not part of the question
String test1 = OS_Result.OSResultStruct.OSBuild;
String test2 = OS_Result.OSResultStruct.OSMajor;

// here is what i would like to be able to do
foreach (string s in OS_Result.OSResultStruct)
{
    // get the string and do some work....
    string test = s;
    //......

}
Run Code Online (Sandbox Code Playgroud)

c# object

8
推荐指数
1
解决办法
3万
查看次数

标签 统计

c# ×1

object ×1