当前位置: 首页>>代码示例>>C#>>正文


C# this.Count方法代码示例

本文整理汇总了C#中this.Count方法的典型用法代码示例。如果您正苦于以下问题:C# this.Count方法的具体用法?C# this.Count怎么用?C# this.Count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在this的用法示例。


在下文中一共展示了this.Count方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AllInOneTrend

 public static bool AllInOneTrend(this IEnumerable<Quote> list)
 {
     return
         list.Skip(list.Count() > 1 ? 1 : 0).Select((q, i) => new { q, i }).All(x => x.q.Close > list.ElementAt(x.i).Close)
         ||
         list.Skip(list.Count() > 1 ? 1 : 0).Select((q, i) => new { q, i }).All(x => x.q.Close < list.ElementAt(x.i).Close);
 }
开发者ID:raimiui,项目名称:EFx,代码行数:7,代码来源:ProjectExtensions.cs

示例2: CapitalizeWord

        public static string CapitalizeWord(this string word)
        {
            char[] tempArray = word.ToCharArray();

            // capitalize first char if not a number
            // if number then probably a numbered book
            int bookNumber;
            if (int.TryParse(Convert.ToString(tempArray[0]), out bookNumber)) // first char is number
            {
                // assume spot 2 is what needs capitalized.
                tempArray[2] = char.ToUpper(tempArray[2]);
                for (int i = 3; i < word.Count(); i++)
                {
                    tempArray[i] = char.ToLower(tempArray[i]);
                }
            }
            else // first char is not number so capitalize it
            {
                tempArray[0] = char.ToUpper(tempArray[0]);
                for (int i = 1; i < word.Count(); i++)
                {
                    tempArray[i] = char.ToLower(tempArray[i]);
                }
            }

            string tempString = "";
            foreach (char i in tempArray)
            {
                tempString += i;
            }
            return tempString;
        }
开发者ID:sorvis,项目名称:Fast-Script,代码行数:32,代码来源:Extentions.cs

示例3: CreateInstallment

        public static ViewPaymentInstallmentItems[] CreateInstallment(this IEnumerable<Installment> input)
        {
            string numberFormat = ConfigurationManager.Format.NUMBER_FORMAT;
            var InstallmentItems = new ViewPaymentInstallmentItems[0];

            if (input.Count() > 0)
            {
                InstallmentItems = new ViewPaymentInstallmentItems[input.Count()];
                var installment = input.ToArray();
                for (int i = 0; i < installment.Count(); i++)
                {
                    InstallmentItems[i] = new ViewPaymentInstallmentItems
                    {
                        No = (i + 1).ToString(numberFormat),
                        InstallmentId = installment[i].Id.ToString("0000000000"),
                        InstalledDate = installment[i].InstallmentDate.ToString(ConfigurationManager.Format.Date_Format),
                        InstalledBy = installment[i].InstallmentBy,
                        Method = installment[i].Method,
                        Amount = installment[i].Amount.ToString(ConfigurationManager.Format.Decimal_Format),
                    };
                }
            }

            return InstallmentItems;
        }
开发者ID:anupong-s,项目名称:Transaction,代码行数:25,代码来源:ViewPayment.cs

示例4: IsEquivalentTo

        public static bool IsEquivalentTo(this IEnumerable<int> first, IEnumerable<int> second)
        {
            if (first == null && second == null)
            {
                return true;
            }

            if (first == null || second == null)
            {
                return false;
            }

            if (first.Count() != second.Count())
            {
                return false;
            }

            for (var i = 0; i < first.Count(); i++)
            {
                if (first.ElementAt(i) != second.ElementAt(i))
                {
                    return false;
                }
            }

            return true;
        }
开发者ID:mr-sandy,项目名称:kola,代码行数:27,代码来源:IntExtensions.cs

示例5: AddConjunctions

        /// <summary>
        /// Add conjunctions, such as commas "," and "ands" to 
        /// concatenate the given phrases into a sentence.
        /// </summary>
        /// <param name="effectSpans">
        /// The lists of lists of <see cref="EffectSpan"/> to
        /// add conjunctions to. This cannot be null and no element
        /// within hte list can be null.
        /// </param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="effectSpans"/> cannot be null and no 
        /// element within it can be null.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// <paramref name="effectSpans"/> cannot be empty.
        /// </exception>
        public static IEnumerable<EffectSpan> AddConjunctions(this IList<List<EffectSpan>> effectSpans)
        {
            if (effectSpans == null)
            {
                throw new ArgumentNullException("effectSpans");
            }
            if (!effectSpans.Any())
            {
                throw new ArgumentException("Cannot be empty", "effectSpans");
            }
            if (effectSpans.Any(x => x == null))
            {
                throw new ArgumentNullException("effectSpans");
            }

            List<EffectSpan> result;

            result = new List<EffectSpan>();
            for (int i = 0; i < effectSpans.Count(); i++)
            {
                result.AddRange(effectSpans[i]);

                if (i < effectSpans.Count() - 2)
                {
                    result.Add(new EffectSpan(", "));
                }
                else if (i == effectSpans.Count() - 2)
                {
                    result.Add(new EffectSpan(" and "));
                }
            }

            return result;
        }
开发者ID:anthonylangsworth,项目名称:GammaWorldCharacter,代码行数:51,代码来源:EffectParserHelper.cs

示例6: SimpleMovingAverage

 /// <summary>
 /// Returns IEnumerable of SMA(x). First (period-1) values returns null value
 /// </summary>        
 public static IEnumerable<decimal?> SimpleMovingAverage(this IEnumerable<decimal> values, int period)
 {
     Contract.Requires(values != null);
     Contract.Requires(period >0 && period <= values.Count());
     var result = Enumerable.Range(1 - period, values.Count()).Select(c => values.Skip(c).Take(period).Sum()/period);
     return Enumerable.Range(0, period - 1).Select(i => null as decimal?).Concat(result.Skip(period - 1).Cast<decimal?>());
 }
开发者ID:kuritka,项目名称:CommodityQuotations,代码行数:10,代码来源:StatisticsEextension.cs

示例7: TypeSequenceIsAssignableFrom

        public static bool TypeSequenceIsAssignableFrom(this IEnumerable<Type> source, IEnumerable<object> sequence)
        {
            var canCast = true;

            if (source.Count() == sequence.Count())
            {
                if (source.Count() > 0)
                {
                    var srcEnum = source.GetEnumerator();
                    var seqEnum = sequence.GetEnumerator();
                    do
                    {
                        if (seqEnum.Current == null)
                        {
                            continue;
                        }

                        canCast = srcEnum.Current.IsAssignableFrom(seqEnum.Current.GetType());
                    }
                    while (srcEnum.MoveNext() && seqEnum.MoveNext() && canCast);
                }
            }
            else
            {
                canCast = false;
            }

            return canCast;
        }
开发者ID:3kthor3adward,项目名称:ce_ps,代码行数:29,代码来源:SequenceCastExtension.cs

示例8: Mean

        public static double Mean(this IEnumerable<double> source)
        {
            if (source.Count() < 1)
                return 0.0;

            double length = source.Count();
            double sum = source.Sum();
            return sum / length;
        }
开发者ID:tohhierallie,项目名称:Project4,代码行数:9,代码来源:Helper.cs

示例9: BranchShort

        public static void BranchShort(this List<object> codeList, Code op, int label)
        {
            Debug.Assert((codeList.Count() - label) < SByte.MaxValue);

            // +2, op code + address code, as backward jump start from first byte of the end of branch command with address
            var address = (byte) -(codeList.Count() - label + 2);
            codeList.Add(op);
            codeList.Add(address);
        }
开发者ID:afrog33k,项目名称:csnative,代码行数:9,代码来源:OpCodeExtentions.cs

示例10: ListEquals

 public static bool ListEquals(this IEnumerable<Type> source, IEnumerable<Type> compare)
 {
     if (source.Count() != compare.Count())
     return false;
       for (var i = 0; i < source.Count(); i++)
     if (source.ElementAt(i) != (compare.ElementAt(i)))
       return false;
       return true;
 }
开发者ID:lukemurray,项目名称:EntityQueryLanguage,代码行数:9,代码来源:ExtensionHelpers.cs

示例11: ToArrayOfVec3F

 public static SbVec3f[] ToArrayOfVec3F(this List<Color> colors)
 {
     var vec = new SbVec3f[colors.Count()];
     for (int i = 0; i < colors.Count(); i++)
     {
         vec[i] = colors[i].ConvertToVec3F();
     }
     return vec;
 }
开发者ID:sparta25,项目名称:3DEngineResearch,代码行数:9,代码来源:ColorsToVec3FConvertorExt.cs

示例12: AddContextAccessor

        public static IServiceCollection AddContextAccessor(this IServiceCollection self)
        {
            if (self.Count(x => x.ServiceType == typeof(IHttpContextAccessor)) == 0)
                self.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();

            if (self.Count(x => x.ServiceType == typeof(IActionContextAccessor)) == 0)
                self.AddSingleton<IActionContextAccessor, ActionContextAccessor>();

            return self;
        }
开发者ID:yonglehou,项目名称:dotNETCore-Extensions,代码行数:10,代码来源:HttpContextAccessorExtensions.cs

示例13: ToStringSeparatedWithAnd

 public static string ToStringSeparatedWithAnd(this List<string> input)
 {
     if (input.Any())
     {
         if (input.Count() == 1)
             return input.First();
         var first = input.Count() == 2 ? input.First() : string.Join(", ", input.Take(input.Count() - 1));
         return string.Format("{0} and {1}", first, input.Last());
     }
     return string.Empty;
 }
开发者ID:RHMGLtd,项目名称:sourcecode,代码行数:11,代码来源:ListExtensions.cs

示例14: AllItemsAreEqual

        /// <summary>
        /// <paramref name="left"/>와 <paramref name="right"/> 시퀀스의 요소들이 모두 같은 지를 판단합니다.
        /// </summary>
        /// <param name="left"></param>
        /// <param name="right"></param>
        /// <returns></returns>
        public static bool AllItemsAreEqual(this IEnumerable<ITimePeriod> left, IEnumerable<ITimePeriod> right) {
            if(left.Count() != right.Count())
                return false;

            var itemCount = left.Count();

            for(var i = 0; i < itemCount; i++) {
                if(Equals(left.ElementAt(i), right.ElementAt(i)) == false)
                    return false;
            }
            return true;
        }
开发者ID:debop,项目名称:NFramework,代码行数:18,代码来源:TimeTool.Validation.cs

示例15: StandardDeviation

 public static double StandardDeviation(this IEnumerable<double> values)
 {
     double ret = 0;
     if (values.Count() > 0)
     {
         //Compute the Average
         double avg = values.Average();
         //Perform the Sum of (value-avg)_2_2
         double sum = values.Sum(d => Math.Pow(d - avg, 2));
         //Put it all together
         ret = Math.Sqrt((sum) / (values.Count() - 1));
     }
     return ret;
 }
开发者ID:davidpodhola,项目名称:sagacious-octo-kumquat,代码行数:14,代码来源:Class1.cs


注:本文中的this.Count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。