我想创建一个接收 3 个字符串作为参数并返回一个对象的方法,该对象包含它们引用这些字符串的三个属性。
没有要复制的“旧对象”。应在此方法中创建属性。
是在C#中用反射来做到这一点吗?如果是这样,怎么办?下面是你喜欢而我做不到的。
protected Object getNewObject(String name, String phone, String email)
{
Object newObject = new Object();
... //I can not add the variables that received by the object parameter here.
return newObject();
}
Run Code Online (Sandbox Code Playgroud)