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


C# List.Contains方法代码示例

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


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

示例1: DecisionMakerType1

        public DecisionMakerType1(
            List<FuzzyVariable> inputVariables,
            FuzzyVariable outputVariable,
            RulesList ruleDefinitions,
            List<string> includedVariables = null)
        {
            if (includedVariables == null)
            {
                includedVariables = (from v in inputVariables select v.Name).ToList();
            }

            this.fsWellEval = new MamdaniFuzzySystem();
            this.fsWellEval.Input.AddRange(from v in inputVariables where includedVariables.Contains(v.Name) select v);
            this.fsWellEval.Output.Add(outputVariable);

            this.RulesDefinitions = new RulesList();
            foreach (var rule in ruleDefinitions.Items)
            {
                string[] splitDef = rule.Definition.Split(
                    new[] { "if", "and", "(", ")" },
                    StringSplitOptions.RemoveEmptyEntries);

                string updatedDef = string.Empty;
                foreach (var condition in splitDef)
                {
                    if (condition == string.Empty)
                    {
                        continue;
                    }

                    var trimmedCondition = condition.Trim();
                    if (trimmedCondition.StartsWith("then"))
                    {
                        updatedDef += trimmedCondition;
                    }
                    else
                    {
                        string variable = trimmedCondition.Split(' ')[0];
                        if (includedVariables.Contains(variable))
                        {
                            string keyword = updatedDef == string.Empty ? "if" : "and";
                            updatedDef += string.Format("{0} ({1}) ", keyword, trimmedCondition);
                        }
                    }
                }

                if (!RulesDefinitions.Items.Exists(r => r.Definition.Equals(updatedDef)))
                {
                    this.RulesDefinitions.Items.Add(new RuleDef { Definition = updatedDef, Weight = rule.Weight });
                    MamdaniFuzzyRule newRule = this.fsWellEval.ParseRule(updatedDef);
                    this.fsWellEval.Rules.Add(newRule);
                }
            }
        }
开发者ID:osnihur,项目名称:fuzzycheck,代码行数:54,代码来源:DecisionMakerType1.cs

示例2: ZonesSelectationViewModel

		public ZonesSelectationViewModel(List<GKZone> zones, bool canCreateNew = false)
		{
			Title = "Выбор зон";
			AddCommand = new RelayCommand<object>(OnAdd, CanAdd);
			RemoveCommand = new RelayCommand<object>(OnRemove, CanRemove);
			AddAllCommand = new RelayCommand(OnAddAll, CanAddAll);
			RemoveAllCommand = new RelayCommand(OnRemoveAll, CanRemoveAll);
			CreateNewCommand = new RelayCommand(OnCreateNew);

			Zones = zones;
			CanCreateNew = canCreateNew;
			TargetZones = new SortableObservableCollection<GKZone>();
			SourceZones = new SortableObservableCollection<GKZone>();

			foreach (var zone in GKManager.DeviceConfiguration.SortedZones)
			{
				if (Zones.Contains(zone))
					TargetZones.Add(zone);
				else
					SourceZones.Add(zone);
			}
			TargetZones.Sort(x => x.No);
			SourceZones.Sort(x => x.No);

			SelectedTargetZone = TargetZones.FirstOrDefault();
			SelectedSourceZone = SourceZones.FirstOrDefault();
		}
开发者ID:xbadcode,项目名称:Rubezh,代码行数:27,代码来源:ZonesSelectationViewModel.cs

示例3: ChooseTurn

        public ITurn ChooseTurn(IPlayerState playerState, IPlayerState opponentState)
        {
            var canSwitchNeuromon = playerState.InactiveNeuromon.Any(n => !n.IsDead);

            var validTurnTypes = new List<int>
            {
                AttackTurnType
            };

            var sb = new StringBuilder();
            sb.AppendLine("1: Attack");

            if (canSwitchNeuromon)
            {
                sb.AppendLine("2: Change Neuromon");
                validTurnTypes.Add(ChangeNeuromonTurnType);
            }

            Console.WriteLine(sb.ToString());

            ITurn selectedTurn = null;
            var turnType = ReadInputUntilValid(input => validTurnTypes.Contains(input));

            if (turnType == AttackTurnType)
            {
                selectedTurn = ChooseAttack(playerState.ActiveNeuromon);
            }
            else if (turnType == ChangeNeuromonTurnType && canSwitchNeuromon)
            {
                selectedTurn = new SwitchActiveNeuromon(SelectActiveNeuromon(playerState, opponentState));
            }

            return selectedTurn;
        }
开发者ID:alexjneves,项目名称:Neuromon,代码行数:34,代码来源:HumanPlayerController.cs

示例4: MPTsSelectationViewModel

		public MPTsSelectationViewModel(List<GKMPT> mpts, bool canCreateNew = false)
		{
			Title = "Выбор МПТ";
			AddCommand = new RelayCommand<object>(OnAdd, CanAdd);
			RemoveCommand = new RelayCommand<object>(OnRemove, CanRemove);
			AddAllCommand = new RelayCommand(OnAddAll, CanAddAll);
			RemoveAllCommand = new RelayCommand(OnRemoveAll, CanRemoveAll);
			CreateNewCommand = new RelayCommand(OnCreateNew);

			MPTs = mpts;
			CanCreateNew = canCreateNew;
			TargetMPTs = new SortableObservableCollection<GKMPT>();
			SourceMPTs = new SortableObservableCollection<GKMPT>();

			foreach (var mpt in GKManager.DeviceConfiguration.MPTs)
			{
				if (MPTs.Contains(mpt))
					TargetMPTs.Add(mpt);
				else
					SourceMPTs.Add(mpt);
			}
			TargetMPTs.Sort(x => x.No);
			SourceMPTs.Sort(x => x.No);

			SelectedTargetMPT = TargetMPTs.FirstOrDefault();
			SelectedSourceMPT = SourceMPTs.FirstOrDefault();
		}
开发者ID:xbadcode,项目名称:Rubezh,代码行数:27,代码来源:MPTsSelectationViewModel.cs

示例5: DirectionsSelectationViewModel

		public DirectionsSelectationViewModel(List<GKDirection> directions)
		{
			Title = "Выбор направлений";
			AddCommand = new RelayCommand<object>(OnAdd, CanAdd);
			RemoveCommand = new RelayCommand<object>(OnRemove, CanRemove);
			AddAllCommand = new RelayCommand(OnAddAll, CanAddAll);
			RemoveAllCommand = new RelayCommand(OnRemoveAll, CanRemoveAll);
			CreateNewCommand = new RelayCommand(OnCreateNew);

			Directions = directions;
			TargetDirections = new SortableObservableCollection<GKDirection>();
			SourceDirections = new SortableObservableCollection<GKDirection>();

			foreach (var direction in GKManager.Directions)
			{
				if (Directions.Contains(direction))
					TargetDirections.Add(direction);
				else
					SourceDirections.Add(direction);
			}
			TargetDirections.Sort(x => x.No);
			SourceDirections.Sort(x => x.No);

			SelectedTargetDirection = TargetDirections.FirstOrDefault();
			SelectedSourceDirection = SourceDirections.FirstOrDefault();
		}
开发者ID:xbadcode,项目名称:Rubezh,代码行数:26,代码来源:DirectionsSelectationViewModel.cs

示例6: GuardZonesSelectationViewModel

		public GuardZonesSelectationViewModel(List<GKGuardZone> guardZones)
		{
			Title = "Выбор охранных зон";
			AddCommand = new RelayCommand<object>(OnAdd, CanAdd);
			RemoveCommand = new RelayCommand<object>(OnRemove, CanRemove);
			AddAllCommand = new RelayCommand(OnAddAll, CanAddAll);
			RemoveAllCommand = new RelayCommand(OnRemoveAll, CanRemoveAll);
			CreateNewCommand = new RelayCommand(OnCreateNew);

			GuardZones = guardZones;
			TargetZones = new SortableObservableCollection<GKGuardZone>();
			SourceZones = new SortableObservableCollection<GKGuardZone>();

			foreach (var guardZone in GKManager.GuardZones)
			{
				if (GuardZones.Contains(guardZone))
					TargetZones.Add(guardZone);
				else
					SourceZones.Add(guardZone);
			}
			TargetZones.Sort(x => x.No);
			SourceZones.Sort(x => x.No);

			SelectedTargetZone = TargetZones.FirstOrDefault();
			SelectedSourceZone = SourceZones.FirstOrDefault();
		}
开发者ID:xbadcode,项目名称:Rubezh,代码行数:26,代码来源:GuardZonesSelectationViewModel.cs

示例7: PumpStationsSelectationViewModel

		public PumpStationsSelectationViewModel(List<GKPumpStation> pumpStations)
		{
			Title = "Выбор насосных станций";
			AddCommand = new RelayCommand<object>(OnAdd, CanAdd);
			RemoveCommand = new RelayCommand<object>(OnRemove, CanRemove);
			AddAllCommand = new RelayCommand(OnAddAll, CanAddAll);
			RemoveAllCommand = new RelayCommand(OnRemoveAll, CanRemoveAll);
			CreateNewCommand = new RelayCommand(OnCreateNew);

			PumpStations = pumpStations;
			TargetPumpStations = new SortableObservableCollection<GKPumpStation>();
			SourcePumpStations = new SortableObservableCollection<GKPumpStation>();

			foreach (var pumpStation in GKManager.PumpStations)
			{
				if (PumpStations.Contains(pumpStation))
					TargetPumpStations.Add(pumpStation);
				else
					SourcePumpStations.Add(pumpStation);
			}
			TargetPumpStations.Sort(x => x.No);
			SourcePumpStations.Sort(x => x.No);

			SelectedTargetPumpStation = TargetPumpStations.FirstOrDefault();
			SelectedSourcePumpStation = SourcePumpStations.FirstOrDefault();
		}
开发者ID:xbadcode,项目名称:Rubezh,代码行数:26,代码来源:PumpStationsSelectationViewModel.cs

示例8: Main

        static void Main(string[] args)
        {
            PrimeCalculator calc = new PrimeCalculator();
            calc.GetAllPrimes(10000);
            for (int n = 1000; n < 10000; n++)
            {
                int d1 = n % 10;
                int d2 = (n / 10) % 10;
                int d3 = (n / 100) % 10;
                int d4 = n / 1000;

                var permutations = Permutator.Permutate(new int[] {d1, d2, d3, d4}.ToList());
                var numbers = new List<int>();
                foreach (var perm in permutations)
                {
                    var num = perm[0] + perm[1] * 10 + perm[2] * 100 + perm[3] * 1000;
                    if (calc.IsPrime((ulong)num) && !numbers.Contains(num) && num>999 && num>=n)
                        numbers.Add(num);
                }
                numbers.Sort();

                for (int i = 1; i < numbers.Count-1; i++)
                {
                    for (int j = i+1; j < numbers.Count; j++)
                    {
                        if (numbers[j]-numbers[i]==numbers[i]-numbers[0])
                            Console.Write("{0}{1}{2}\n", numbers[0], numbers[i], numbers[j]);
                    }
                }
            }
        }
开发者ID:balazsmolnar,项目名称:Euler,代码行数:31,代码来源:Program.cs

示例9: DelaysSelectationViewModel

		public DelaysSelectationViewModel(List<GKDelay> delays)
		{
			Title = "Выбор задержек";
			AddCommand = new RelayCommand<object>(OnAdd, CanAdd);
			RemoveCommand = new RelayCommand<object>(OnRemove, CanRemove);
			AddAllCommand = new RelayCommand(OnAddAll, CanAddAll);
			RemoveAllCommand = new RelayCommand(OnRemoveAll, CanRemoveAll);
			CreateNewCommand = new RelayCommand(OnCreateNew);

			Delays = delays;
			TargetDelays = new SortableObservableCollection<GKDelay>();
			SourceDelays = new SortableObservableCollection<GKDelay>();

			foreach (var delay in GKManager.DeviceConfiguration.Delays)
			{
				if (Delays.Contains(delay))
					TargetDelays.Add(delay);
				else
					SourceDelays.Add(delay);
			}
			TargetDelays.Sort(x => x.No);
			SourceDelays.Sort(x => x.No);

			SelectedTargetDelay = TargetDelays.FirstOrDefault();
			SelectedSourceDelay = SourceDelays.FirstOrDefault();
		}
开发者ID:xbadcode,项目名称:Rubezh,代码行数:26,代码来源:DelaysSelectationViewModel.cs

示例10: AddGroup

        public ActionResult AddGroup(Web_UserGroup model)
        {
            ViewBag.ALLFunctions = new Web_Sys_FunctionBLL().GetAllFunctions(dbParm);
            try
            {
                string t = Request["FunctionId"].ToString();//获取选中的分类ID格式为("1,2,3”)不包含括号。
                List<Int32> idlist = new List<int>();
                if (!string.IsNullOrEmpty(t))
                {
                    if (t.Contains(","))
                    {
                        foreach (var each in t.Split(',').ToList())
                        {
                            idlist.Add(Convert.ToInt32(each));
                        }
                    }
                    else
                    {
                        idlist.Add(Convert.ToInt32(t));
                    }
                }
                IEnumerable<Web_Sys_Function> selectedFuncs = new Web_Sys_FunctionBLL().GetAllFunctions(dbParm).Where(p => idlist.Contains(p.ID));
                if (model.Group_ID == 0) //New
                {
                    model.Web_Sys_Functions = selectedFuncs.ToList();
                    //model.Web_Sys_Functions = new List<Web_Sys_Function>();
                    //selectedFuncs.ToList().ForEach(f => model.Web_Sys_Functions.Add(f));
                    groupBLL.AddNew(model, dbParm);
                }
                else                    //Edit
                {
                    List<Web_Sys_Function> originalFuncs = groupBLL.Get(model.Group_ID, dbParm).Web_Sys_Functions;
                    model.Web_Sys_Functions = originalFuncs;
                    //要删除的function
                    var dlist = originalFuncs.Where(p => !selectedFuncs.Contains(p)).ToList();
                    //要添加的function
                    var alist = selectedFuncs.Where(p => !originalFuncs.Contains(p)).ToList();
                    foreach (var item in dlist)
                    {
                        model.Web_Sys_Functions.Remove(item);
                    }
                    foreach (var item in alist)
                    {
                        model.Web_Sys_Functions.Add(item);
                    }
                    groupBLL.Update(model, dbParm);
                }

                ViewBag.ALLFunctions = new Web_Sys_FunctionBLL().GetAllFunctions(dbParm);
                return null;
                //return View();
            }
            catch (Exception ex)
            {
                var y = ex.InnerException;
                return View(model);
            }
        }
开发者ID:rogerxing90,项目名称:AHome,代码行数:58,代码来源:ManageController.cs

示例11: GetArea

        public Zone_Area GetArea(ushort PinX, ushort PinY, byte Realm, List<Zone_Area> Excepts=null)
        {
            foreach(Zone_Area Area in Areas)
            {
                if (Area.Realm == Realm && Area.IsOnArea(PinX,PinY))
                    if (Excepts == null || !Excepts.Contains(Area))
                        return Area;
            }

            return null;
        }
开发者ID:Necrosummon,项目名称:WarEmu,代码行数:11,代码来源:AreaMapMgr.cs

示例12: UpdateIgnoredExtensionsFilter

        public void UpdateIgnoredExtensionsFilter(List<string> _ignoredExtensions)
        {
            Debug.Assert(_ignoredExtensions != null);

            ExtensionFilter.Set(item =>
            {
                var file = item as FileInfo;
                Debug.Assert(file != null);

                return !_ignoredExtensions.Contains(Path.GetExtension(file.Name));
            });
        }
开发者ID:mkramers,项目名称:Projects,代码行数:12,代码来源:FileFilter.cs

示例13: GetFileDates

 static List<DateTime> GetFileDates(string folderPath)
 {
     List<DateTime> result = new List<DateTime>();
     string[] files = Directory.GetFiles(folderPath,"*.requestData");
     foreach (string file in files)
     {
         DateTime dt = FileUtils.FileNameToDate(file);
         if (!result.Contains(dt))
             result.Add(dt);
     }
     return result;
 }
开发者ID:demonix,项目名称:KeClientTracer,代码行数:12,代码来源:Program.cs

示例14: CreateNewCaption

		string CreateNewCaption(List<string> otherCaptions)
		{
			var defaultCaption = "Новый макет";
			var counter = 1;
			var newCaption = defaultCaption;
			while (otherCaptions.Contains(newCaption))
			{
				newCaption = string.Format("{0}({1})", defaultCaption, counter);
				counter++;
			}
			return newCaption;
		}
开发者ID:xbadcode,项目名称:Rubezh,代码行数:12,代码来源:Layout.cs

示例15: btnImport_Click

 private void btnImport_Click(object sender, EventArgs e)
 {
     //整体表格
     var multilanFolder = ctlMultiLanFolder.SelectedPathOrFileName;
     //整理出最大列表,防止文件之间出现单词表格不同
     var uuiDs = new List<string>();
     uuiDs.Clear();
     if (!string.IsNullOrEmpty(multilanFolder))
     {
         //便利整个文件夹,获得语言字典
         foreach (var filename in Directory.GetFiles(multilanFolder))
         {
             StringResource.InitLanguage(filename);
             var singleDic = new Dictionary<string, string>();
             foreach (var item in StringResource.StringDic)
             {
                 if (!uuiDs.Contains(item.Key)) uuiDs.Add(item.Key);
                 singleDic.Add(item.Key, item.Value);
             }
             _multiLanguageDictionary.Add(StringResource.LanguageType, singleDic);
         }
     }
     //将数据放入ListView视图
     lstMultiLan.Clear();
     //Header
     lstMultiLan.Columns.Add("统一标示");
     for (var i = 0; i < _multiLanguageDictionary.Keys.Count; i++)
     {
         lstMultiLan.Columns.Add(_multiLanguageDictionary.Keys.ElementAt(i));
     }
     //Details
     for (var i = 0; i < uuiDs.Count; i++)
     {
         var item = new ListViewItem(uuiDs[i]);
         for (var j = 0; j < _multiLanguageDictionary.Keys.Count; j++)
         {
             if (_multiLanguageDictionary[_multiLanguageDictionary.Keys.ElementAt(j)].ContainsKey(uuiDs[i]))
             {
                 item.SubItems.Add(_multiLanguageDictionary[_multiLanguageDictionary.Keys.ElementAt(j)][uuiDs[i]]);
             }
             else
             {
                 item.SubItems.Add("");
             }
         }
         lstMultiLan.Items.Add(item);
     }
     Utility.ListViewColumnResize(lstMultiLan);
 }
开发者ID:jango2015,项目名称:MongoCola,代码行数:49,代码来源:frmEditor.cs


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