[英]Pass System .Property name as function parameter
I want to create a function which stores some value within 我想创建一个在其中存储一些值的函数
System.Property.Default.my_property. System.Property.Default.my_property。
void foo(property_name, string property_value)
{
System.Property.Default.property_name = property_value;
}
Calls would look like this 通话看起来像这样
foo(my_first_prop, "first");
foo(my_second_prop, "second")
What would be the bast way to do this? 这样做的最佳方式是什么?
In your code, 'property_name'
should be a string, then you can call it like this: 在您的代码中,
'property_name'
应该是一个字符串,然后可以这样调用它:
void foo(string property_name, string property_value)
{
Properties.Settings.Default[property_name] = property_value;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.