我正在尝试编写一个函数,它将使用如下语法提取属性的名称和类型:
private class SomeClass
{
Public string Col1;
}
PropertyMapper<Somewhere> propertyMapper = new PropertyMapper<Somewhere>();
propertyMapper.MapProperty(x => x.Col1)
Run Code Online (Sandbox Code Playgroud)
有没有办法将属性传递给函数而不对此语法进行任何重大更改?
我想获取属性名称和属性类型.
所以在下面的例子中我想要检索
Name = "Col1" 和 Type = "System.String"
有人可以帮忙吗?