本文整理匯總了C#中System.Char.Aggregate方法的典型用法代碼示例。如果您正苦於以下問題:C# Char.Aggregate方法的具體用法?C# Char.Aggregate怎麽用?C# Char.Aggregate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Char
的用法示例。
在下文中一共展示了Char.Aggregate方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Run
public static void Run()
{
{
// IObservable<TSource> Aggregate<TSource>(
// this IObservable<TSource> source,
// Func<TSource, TSource, TSource> accumulator)
var numbers = Observable.Range(0, 10);
var sum = numbers.Aggregate(0, (acc, currentValue) => acc + currentValue);
sum.Dump("sum");
// problem
// 1. must be same type, 2. need at least one value
}
{
// IObservable<TAccumulate> Aggregate<TSource, TAccumulate>(
// this IObservable<TSource> source,
// TAccumulate seed,
// Func<TAccumulate, TSource, TAccumulate> accumulator)
var chars = new Char[] { 'a', 'b', 'c' }.ToObservable();
var count = chars.Aggregate(0, (acc, _) => acc + 1);
count.Dump("count");
}
{
//
var numbers = new Subject<int>();
var scan = numbers.Scan(0, (acc, current) => acc + current);
numbers.Dump("numbers");
scan.Dump("scan");
numbers.OnNext(1);
numbers.OnNext(2);
numbers.OnNext(3);
numbers.OnCompleted();
// source.Aggregate(0, (acc, current) => acc + current);
// is equivalent to
// source.Scan(0, (acc, current) => acc + current).TakeLast();
}
}