當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。