更新时间:2023-12-06 17:33:22
使用(编辑 - 根据评论):
use (EDIT - as per comment):
string s = c.GetType().GetProperty ("S").GetGetMethod().Invoke (c, null).ToString();
它为您提供实例 c
的名为 S
的(公共)属性的值,而不管 c
的类型如何,并且不会根本不使用 LINQ,尽管我必须承认我不明白为什么 LINQ 应该是一个问题...
It gives you the value of the (public) property named S
of the the instance c
regardless of the type of c
and doesn't use LINQ at all although I must admit that I don't see why LINQ should be a problem...