本文整理匯總了C#中System.Dynamic.ExpandoObject.CalculateNumber方法的典型用法代碼示例。如果您正苦於以下問題:C# ExpandoObject.CalculateNumber方法的具體用法?C# ExpandoObject.CalculateNumber怎麽用?C# ExpandoObject.CalculateNumber使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Dynamic.ExpandoObject
的用法示例。
在下文中一共展示了ExpandoObject.CalculateNumber方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Main
static void Main(string[] args)
{
dynamic person = new ExpandoObject();
person.Name = "Test";
person.Age = 30;
person.Address = "TestAddress";
// print the members
PrintMembers(person);
// remove a member
(person as IDictionary<string, object>).Remove("Address");
Console.WriteLine();
PrintMembers(person);
// cast expando object to person wil throw exception
//Person realPerson = person;
//Console.WriteLine("I'm the real person");
//Console.WriteLine(string.Format("{0} : {1}", "Name", realPerson.Name));
dynamic person2 = new { Name = "Test1", Age = 100, Address = "Somewhere" };
Console.WriteLine();
PrintMembers(person2);
// test method
person.Talk = (Action)(() => Console.WriteLine("I can talk"));
person.Talk();
// test function
person.CalculateNumber = (Func<int, int, int>)((fist, second) => fist + second);
Console.WriteLine(string.Format("I can calculate numbers : {0}", person.CalculateNumber(10, 10)));
Console.ReadLine();
}