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


C# Int32.Contains方法代码示例

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


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

示例1: GetPageSizes

 internal static IEnumerable<SelectListItem> GetPageSizes(Int32[] pageSizes = null, Int32? currentSize = null)
 {
     if (pageSizes == null)
         pageSizes = TableModel.DefaultPageSizes;
     if (currentSize.HasValue && !pageSizes.Contains(currentSize.Value))
         pageSizes = pageSizes.Union(new[] { currentSize.Value }).OrderBy(p => p).ToArray();
     return pageSizes.Select(i => new SelectListItem { Text = i.ToString(), Value = i.ToString(), Selected = i == TableModel.DefaultPageSize });
 }
开发者ID:artiomchi,项目名称:FlexLabs.Util.Web,代码行数:8,代码来源:TableModel.cs

示例2: TranslateExtractSource

        private Int32 TranslateExtractSource( ExtractSource extractSource, Generation generation, bool femalesOnly, Int32[] passoverValues, DataTable dtImport )
        {
            Int32 gen1ReponseRecordsAddedCount = 0;
            LinksDataSet.tblVariableRow[] drsVariablesToTranslate = VariablesToTranslate(extractSource);
            _dsLinks.tblResponse.BeginLoadData();

            string subjectIDColumnName;
            string genderColumnName;
            switch ( generation ) {
                case Generation.Gen1:
                    subjectIDColumnName = Constants.Gen1SubjectIDColumn;
                    genderColumnName = Constants.Gen1GenderColumn;
                    break;
                case Generation.Gen2:
                    subjectIDColumnName = Constants.Gen2SubjectIDColumn;
                    genderColumnName = Constants.Gen2GenderColumn;
                    break;
                default:
                    throw new ArgumentOutOfRangeException("generation", generation, "The generation value was not recognized.");
            }

            foreach ( DataRow drImport in dtImport.Rows ) {
                GenderBothGenerations gender = (GenderBothGenerations)Convert.ToInt32(drImport[genderColumnName]);
                if ( !femalesOnly || gender == GenderBothGenerations.Female ) {
                    Int32 subjectID = Convert.ToInt32(drImport[subjectIDColumnName]);
                    Int32 subjectTag = Retrieve.SubjectTagFromSubjectIDAndGeneration(subjectID, generation, _dsLinks);
                    foreach ( LinksDataSet.tblVariableRow drVariable in drsVariablesToTranslate ) {
                        string columnName = drVariable.VariableCode;
                        LinksDataSet.tblResponseRow drResponse = _dsLinks.tblResponse.NewtblResponseRow();
                        drResponse.Generation = (byte)generation;
                        drResponse.SubjectTag = subjectTag;
                        drResponse.ExtendedID = GetExtendedID(subjectTag);
                        drResponse.SurveySource = drVariable.SurveySource;
                        drResponse.SurveyYear = drVariable.SurveyYear;
                        drResponse.Item = drVariable.Item; //if ( drResponse.Item == 13 ) Trace.Assert(true);
                        drResponse.Value = Convert.ToInt32(drImport[columnName]);

                        LinksDataSet.tblItemRow drItem = drVariable.tblItemRow;
                        if ( !(drItem.MinValue <= drResponse.Value && drResponse.Value <= drItem.MaxValue) )
                            throw new InvalidOperationException(string.Format("For Item '{0}', variable '{1}', the value '{2}' exceeded the bounds of [{3}, {4}].", drVariable.Item, drVariable.ID, drResponse.Value, drItem.MinValue, drItem.MaxValue));
                        if ( 0 <= drResponse.Value && drResponse.Value < drItem.MinNonnegative )
                            throw new InvalidOperationException(string.Format("For Item '{0}', variable '{1}', the value '{2}' dipped below the minimum nonnegative value of {3}.", drVariable.Item, drVariable.ID, drResponse.Value, drItem.MinNonnegative));
                        if ( !passoverValues.Contains(drResponse.Value) ) {
                            drResponse.LoopIndex = drVariable.LoopIndex;
                            _dsLinks.tblResponse.AddtblResponseRow(drResponse);
                            gen1ReponseRecordsAddedCount += 1;
                        }
                    }
                }
            }
            _dsLinks.tblResponse.EndLoadData();
            return gen1ReponseRecordsAddedCount;
        }
开发者ID:LiveOak,项目名称:NlsyLinksDetermination,代码行数:53,代码来源:Response.cs

示例3: RandomArrayFill

        /// <summary>
        ///  Fills an array of size N with the numbers from 1 to N in random order without duplicates
        /// </summary>
        /// <param name="arrayToFill">Array To fill</param>
        public static void RandomArrayFill(Int32[] arrayToFill)
        {
            int n = arrayToFill.Length;

            Int32 currentNum = Int32.MinValue;
            Random randNum = new Random();

            //Input cleaning
            for (int i = 0; i < n; i++)
            {
                arrayToFill[i] = Int32.MinValue;
            }

            //Array filled by rondom number form 1 to n
            for (int i = 0; i < n; i++)
            {
                currentNum = randNum.Next(0, n) + 1;

                while (arrayToFill.Contains(currentNum))
                {
                    currentNum = randNum.Next(0, n) + 1;
                }

                arrayToFill[i] = currentNum;

            }
        }
开发者ID:sisay82,项目名称:Code4Fun_Geri_2015-06-29,代码行数:31,代码来源:Utility.cs


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