111,126
社区成员
发帖
与我相关
我的任务
分享using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
DataContract contract = new DataContract();
contract.ProductId = new decimal(20);
object temp = MethodA(contract, "ProductId");
Console.WriteLine(temp);
Console.ReadKey();
}
private static object MethodA(object obj, string property)
{
return obj.GetType().InvokeMember(property, System.Reflection.BindingFlags.GetProperty, null, obj, null);
}
}
}