我正在合并两个任意对象:
#define theValue 1000
static std::string str = R"(
foo )" + theValue + R"( bar
)";
当我调用该方法时,我收到此错误:
public void MergeWorkSpaceObjs<T>(T source, T target)
{
Type t = typeof(T);
var properties = t.GetProperties().Where(prop =>
prop != null &&
prop.CanRead &&
prop.CanWrite);
foreach (var prop in properties)
{
var value = prop.GetValue(source);
if (value != null)
{
prop.SetValue(target, value);
}
}
var fields = t.GetFields();
foreach (var fi in fields)
{
var targetField = t.GetField(fi.Name);
targetField.SetValue(target, fi.GetValue(source));
}
}
我不确定该错误究竟意味着什么。在一些谷歌搜索之后,看起来错误与缺少的类实例化相关或者存在空属性,但我不确定在哪里,我还是C#的新手。
该错误意味着什么,我该如何解决?