Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/278.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# 更改对象的值';s属性,具体取决于属性';姓名_C#_Reflection_Properties_Variable Assignment_Variable Names - Fatal编程技术网

C# 更改对象的值';s属性,具体取决于属性';姓名

C# 更改对象的值';s属性,具体取决于属性';姓名,c#,reflection,properties,variable-assignment,variable-names,C#,Reflection,Properties,Variable Assignment,Variable Names,我想根据属性的名称更改对象中目标属性的值。 例如: 我该怎么做呢 谢谢您可以使用设置值: property.SetValue(myObject, -1, null); 您可以阅读文档:“您应该在标题中使用标记的唯一时间是当它们与标题的对话基调有机时。”-因此,我已经从您的问题标题中删除了“(C#)”标记。property.SetValue(myObject,-1)这是否回答了您的问题?及及 property.SetValue(myObject, -1, null);

我想根据属性的名称更改对象中目标属性的值。 例如:

我该怎么做呢


谢谢

您可以使用
设置值

property.SetValue(myObject, -1, null);

您可以阅读文档

:“您应该在标题中使用标记的唯一时间是当它们与标题的对话基调有机时。”-因此,我已经从您的问题标题中删除了“(C#)”标记。
property.SetValue(myObject,-1)
这是否回答了您的问题?及及
property.SetValue(myObject, -1, null);