本文整理匯總了C#中System.Dynamic.ExpandoObject.Increment方法的典型用法代碼示例。如果您正苦於以下問題:C# ExpandoObject.Increment方法的具體用法?C# ExpandoObject.Increment怎麽用?C# ExpandoObject.Increment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Dynamic.ExpandoObject
的用法示例。
在下文中一共展示了ExpandoObject.Increment方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ExpandoDemo
public static void ExpandoDemo()
{
dynamic ex = new ExpandoObject();
ex.Name = "Keith";
ex.Age = "pi";
Console.WriteLine(new { ex.Name, ex.Age, ex.ShirtColor });
ex.Increment = new Func<int, int>(i => i + 1);
Console.WriteLine("1 + 1 = {0}", ex.Increment(1));
}
示例2: ExpandoObjectDemo
public void ExpandoObjectDemo()
{
dynamic dyn = new ExpandoObject();
dyn.number = 1;
dyn.Increment = new Action(() => { dyn.number++; });
Console.WriteLine(dyn.number);
dyn.Increment();
Console.WriteLine(dyn.number);
foreach (var propery in (IDictionary<string, object>)dyn)
{
Console.WriteLine(propery.Key+":"+propery.Value);
}
((INotifyPropertyChanged)dyn).PropertyChanged += DynamicDemo_PropertyChanged;
dyn.name = "changed";
dyn.name = "another";
}
示例3: Expando
public static void Expando()
{
dynamic ex = new ExpandoObject();
ex.Name = "Keith";
Console.WriteLine(ex.Name);
ex.Increment = new Func<int, int>(i => i + 1);
Console.WriteLine("1 + 1 = {0}", ex.Increment(1));
}