嘿,我一直在将一个简单的 Linq 语句从查询语法转换为 C# 中的流畅语法。我认为这是可能的,但我需要提示。
from property in target.GetType().GetProperties()
select new
{
Name = property.Name,
Value = property.GetValue(target, null)
};
为了..
var props = target.GetType().GetProperties().Select(p=>p.Name.... )
选择
后我需要更改什么?
最佳答案
var props = target
.GetType()
.GetProperties()
.Select(p => new {
Name = p.Name,
Value = p.GetValue(target, null)
});
关于c# - 将 LINQ 语句从查询转换为流利的 c# 语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5970055/