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


C# List.RemoveAll方法代码示例

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


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

示例1: GetMostCommonElementList

        private static List<int> GetMostCommonElementList(List<int> intsList)
        {
            intsList.Sort();
            List<int> listWithRemovedElements =new List<int>(intsList);
            int listCount = intsList.Count;
            int currentNumber = intsList[0];

            int occurance = 1;
            for (int i = 0; i <= listCount - 1; i++)
            {
                if (i == listCount - 1 && intsList[i] != intsList[i-1])
                {
                    currentNumber = intsList[i];
                    listWithRemovedElements.RemoveAll(x => x == currentNumber);
                }
                else if (intsList[i] == intsList[i + 1])
                {
                    occurance++;
                }
                else
                {
                    if (occurance % 2 != 0)
                    {
                        currentNumber = intsList[i];
                        listWithRemovedElements.RemoveAll(x => x == currentNumber);
                    }
                    occurance = 1;
                }
            }

            return listWithRemovedElements;
        }
开发者ID:NikolaNikushev,项目名称:DSA,代码行数:32,代码来源:RemoveOddOccurances06.cs

示例2: Parse

        public override bool Parse(List<string> aAnswer)
        {
            if (!aAnswer.Contains(BASE_ERROR) && aAnswer.Contains("OK"))
            {
                aAnswer.RemoveAll(OKString);
                aAnswer.RemoveAll(this.ReadParamsClone);
                aAnswer.RemoveAll(String.IsNullOrEmpty);

                if (aAnswer.Count == 1)
                {
                    string[] zSplit = aAnswer[0].Split(new Char[] { ' ', ' ', ' ' });
                    if (zSplit.Count() == 3)
                    {
                        String zCleanSN = TrimValue(zSplit[2]);
                        SerialNumber = zCleanSN;
                        return true;
                    }
                    else
                    {
                        _logger.Debug("InCorrect Params Count: {0}", zSplit.Count());
                        return false;
                    }
                }
                else
                    return false;
            } else
                return false;
        }
开发者ID:MegaYanuardi,项目名称:GSMLibrary.Net,代码行数:28,代码来源:SerialNumberCommand.cs

示例3: CorruptEntityAnimations_Func

        private bool CorruptEntityAnimations_Func()
        {
            List<string> tocorrupt = new List<string>();

            if (!LoadXMLAndModify("./entities2.xml", delegate (XmlDocument XML)
            {
                tocorrupt.AddRange(from XmlNode n in XML.LastChild.ChildNodes select n.Attributes["anm2path"].Value);
            }))
            { return false; }

            tocorrupt.RemoveAll(x => x.Length == 0);
            tocorrupt.RemoveAll(x => x.Contains("Fireworks") == true);

            if (!tocorrupt.Select(corruptfile => "./gfx/" + corruptfile)
                .All(toopen => LoadXMLAndModify(toopen, delegate (XmlDocument XML)
                {
                    AnimCont A = new AnimCont();
                    foreach (XmlNode frame in XML.GetElementsByTagName("Frame"))
                    {
                        CorruptFrame(frame, A);
                    }
                })))
            { return false; }

            List<string> itemfiles = Safe.GetFiles("./gfx/characters");
            return itemfiles.All(file => LoadXMLAndModify(file, delegate (XmlDocument XML)
            {
                AnimCont A = new AnimCont();
                foreach (XmlNode frame in XML.GetElementsByTagName("Frame"))
                {
                    CorruptFrame(frame, A);
                }
            }));
        }
开发者ID:RedSpah,项目名称:Undefined_3.0,代码行数:34,代码来源:Methods2.cs

示例4: PrepareProducts

        private void PrepareProducts(List<Product> products)
        {
            products.RemoveAll(x => x.Name.Contains("*"));

            var coupon = products.FirstOrDefault(x => x.Name.Contains("$"));
            if (coupon != null)
            {
                for (var i = 0; i < coupon.Quantity; i++)
                {
                    var bread = products.First(x => x.Name.Contains("хляб") && !x.Name.Contains("$") && x.Quantity > 0 && x.SellingPrice > coupon.SellingPrice * -1);
                    bread.Quantity--;

                    var breadWithCouponName = bread.Name + " с купон";

                    var breadWithCoupon = products.FirstOrDefault(x => x.Name == breadWithCouponName);

                    if (breadWithCoupon != null)
                    {
                        breadWithCoupon.Quantity++;
                    }
                    else
                    {
                        breadWithCoupon = new Product { Name = breadWithCouponName, SellingPrice = bread.SellingPrice - coupon.SellingPrice * -1, Quantity = 1 };
                        products.Add(breadWithCoupon);
                    }
                }

                products.RemoveAll(x => x.Quantity == 0);
                products.RemoveAll(x => x.Name.Contains("$"));
            }
        }
开发者ID:svstoichkov,项目名称:Eugenie-v3,代码行数:31,代码来源:FiscalPrinterHandler.cs

示例5: Main

    static void Main(string[] args)
    {
        Console.Write("Show all prime numbers from 1 to ");
        int n = int.Parse(Console.ReadLine());
        List<int> numbers = new List<int>();
        numbers.Add(2); //adding 2 in the list
        for (int i = 0; i < n - 2; i += 2) //so it can show numbers from 3 to N and excluding all even numbers
        {
            numbers.Add(i + 3);
        }

        int range = (int)(Math.Sqrt(n)); //check for divisors up to the square root of N

        //first removing numbers divisible by 3, 5, 7, 11
        numbers.RemoveAll(item => item % 3 == 0 && item != 3);
        numbers.RemoveAll(item => item % 5 == 0 && item != 5);
        numbers.RemoveAll(item => item % 7 == 0 && item != 7);
        numbers.RemoveAll(item => item % 11 == 0 && item != 11);

        //then checking the rest divisiors with the help of the range
        for (int i = 13; i < range; i += 2)
        {
            numbers.RemoveAll(item => item % i == 0);
        }

        //printing numbers
        Console.WriteLine("The prime numbers from 1 to N are: ");
        Console.WriteLine(String.Join(", ", numbers));
    }
开发者ID:kris4o1993,项目名称:Telerik-Academy,代码行数:29,代码来源:Prime.cs

示例6: BuildFolderList

		protected void BuildFolderList() {
			List<FileData> lstFolders = new List<FileData>();

			string sRoot = Server.MapPath("~/");

			string[] subdirs;
			try {
				subdirs = Directory.GetDirectories(sRoot);
			} catch {
				subdirs = null;
			}

			if (subdirs != null) {
				foreach (string theDir in subdirs) {
					string w = FileDataHelper.MakeWebFolderPath(theDir);
					lstFolders.Add(new FileData { FileName = w, FolderPath = w, FileDate = DateTime.Now });
				}
			}

			lstFolders.RemoveAll(f => f.FileName.ToLower().StartsWith(SiteData.AdminFolderPath));
			lstFolders.RemoveAll(f => f.FileName.ToLower().StartsWith("/bin/"));
			lstFolders.RemoveAll(f => f.FileName.ToLower().StartsWith("/obj/"));
			lstFolders.RemoveAll(f => f.FileName.ToLower().StartsWith("/app_data/"));

			ddlFolders.DataSource = lstFolders.OrderBy(f => f.FileName);
			ddlFolders.DataBind();
		}
开发者ID:tridipkolkata,项目名称:CarrotCakeCMS,代码行数:27,代码来源:PhotoGalleryAdminImportWP.ascx.cs

示例7: Main

    public static void Main (string[] args) {
        var l = new List<string> {
            "A", "A", "B", "C", "D"
        };

        PrintItems(l);
        Console.WriteLine(l.RemoveAll((s) => s == "A"));
        PrintItems(l);
        Console.WriteLine(l.RemoveAll((s) => s == "Q"));
        PrintItems(l);
    }
开发者ID:GlennSandoval,项目名称:JSIL,代码行数:11,代码来源:ListRemoveAll.cs

示例8: FilterForApplicableTFMRIDPairs

 public static List<TfmRidPair> FilterForApplicableTFMRIDPairs(List<TfmRidPair> tfmRidPairs,
     string framework, string runtimeIdentifier)
 {
     if (framework != null)
     {
         tfmRidPairs.RemoveAll(x => !framework.Equals(x.framework));
     }
     if (runtimeIdentifier != null)
     {
         tfmRidPairs.RemoveAll(x => !runtimeIdentifier.Equals(x.runtimeIdentifier));
     }
     
     return tfmRidPairs;
 }
开发者ID:roncain,项目名称:buildtools,代码行数:14,代码来源:FilterRuntimesFromSupports.cs

示例9: OnHierarchyChange

        void OnHierarchyChange()
        {
            emitters = new List<StudioEventEmitter>(Resources.FindObjectsOfTypeAll<StudioEventEmitter>());

            if (!levelScope)
            {
                emitters.RemoveAll(x => PrefabUtility.GetPrefabType(x) != PrefabType.Prefab);
            }

            if (!prefabScope)
            {
                emitters.RemoveAll(x => PrefabUtility.GetPrefabType(x) == PrefabType.Prefab);
            }            
        }
开发者ID:mutatis,项目名称:WereWolfTheApocalipse,代码行数:14,代码来源:FindAndReplace.cs

示例10: generate_btn_Click

        // Event handlers
        private void generate_btn_Click(object sender, EventArgs e)
        {
            status_bar.Value = 0;

            string password = "";

            List<char> choices = new List<char>();

            if(lower_box.Checked) {
                choices.AddRange(lower);
            }
            if(upper_box.Checked) {
                choices.AddRange(upper);
            }
            if(num_box.Checked) {
                choices.AddRange(numbers);
            }
            if(sym_box.Checked) {
                choices.AddRange(symbols);
            }
            if(include_text.Text.Length > 0) {
                choices.AddRange(include_text.Text.ToCharArray());
            }

            if(exclude_text.Text.Length > 0) {
                for(int i = 0; i < exclude_text.Text.Length; i++) {
                    choices.RemoveAll(item => item == exclude_text.Text[i]);
                }
            }

            char next;
            for(int i = 0; i < (int)passlength_select.Value; i++) {
                if(choices.Count > 0) {
                    next = choices[rand.Next(choices.Count)];
                } else {
                    next = ' ';
                }

                if(repeat_box.Checked) {
                    choices.RemoveAll(item => item == next);
                }

                password += next;
            }

            status_bar.Value = 100;
            pass_text.Text = password;
        }
开发者ID:LRB-Game-Tools,项目名称:PasswordGen,代码行数:49,代码来源:PasswordGen.cs

示例11: ReadFile

        public static List<string> ReadFile(string filename)
        {
            List<string> listFileContent = new List<string>();

            StringBuilder stringBuilder = new StringBuilder();
            using (FileStream fileStream = new FileStream(filename, FileMode.Open, FileAccess.Read))
            {
                using (StreamReader streamReader = new StreamReader(fileStream))
                {
                    char[] fileContents = new char[_bufferSize];
                    int charsRead = streamReader.Read(fileContents, 0, _bufferSize);

                    // Can't do much with 0 bytes
                    //if (charsRead == 0)
                    //    throw new Exception("File is 0 bytes");

                    while (charsRead > 0)
                    {
                        stringBuilder.Append(fileContents);
                        charsRead = streamReader.Read(fileContents, 0, _bufferSize);
                    }

                    string[] contentArray = stringBuilder.ToString().Split(new char[] { '\r', '\n' });
                    foreach (string line in contentArray)
                    {
                        listFileContent.Add(line.Replace("#", ""));
                    }
                    listFileContent.RemoveAll(s => string.IsNullOrEmpty(s));
                }
            }
            return listFileContent;
        }
开发者ID:prog-moh,项目名称:twtboard,代码行数:32,代码来源:GlobusFileHelper.cs

示例12: Handle

        public NanoHttpResponse Handle(NanoHttpRequest request)
        {
            try
            {
                var places = new List<string>(File.ReadAllLines(Strings.Places));
                var place = request.Address.Substring(5);

                bool found = false;

                if (places.Contains(place))
                {
                    found = true;
                    places.RemoveAll(s => s == place);
                }

                File.WriteAllLines(Strings.Places, places.ToArray());
                return new NanoHttpResponse(StatusCode.Ok, (found?"Deleted ":"Not found ") + place);
            }

            catch (Exception e)
            {
                NotificationHandler.Instance.AddNotification("Не удалось обновить places.txt");
                return new ErrorHandler(StatusCode.InternalServerError, e.ToString()).Handle(request);
            }
        }
开发者ID:Bit-notes,项目名称:nanoboard,代码行数:25,代码来源:DelPlaceHandler.cs

示例13: Simp

 private static List<int> Simp(int i)
 {
     List<int> list;
     if (max_num >= i)
     {
         list = new List<int>(good_num);
         list.RemoveAll(EndS);
     }
     else
     {
         list = new List<int>(good_num);
         for (int j = 1; j < i - max_num + 1; j++)
         {
             if (IsSimp(max_num + j))
             {
                 list.Add(max_num + j);
             }
         }
     }
     /*list = new List<int>();
     for (int j = 1; j < i + 1; j++)
     {
         if (IsSimp(j))
         {
             Thread.Sleep(2);
             list.Add(j);
         }
     }*/
     return list;
 }
开发者ID:ALEXSSS,项目名称:store_of_my_project1,代码行数:30,代码来源:Server.cs

示例14: OnGetValue

        protected override void OnGetValue(PropertySpecEventArgs e)
        {
            base.OnGetValue(e);

            var attributeList = new List<Attribute>();
            attributeList.AddRange(e.Property.Attributes.ToList());

            //check all of the attributes: if we find a dynamic one, evaluate it and possibly add/overwrite a static attribute
            foreach (Attribute customAttribute in e.Property.Attributes)
            {
                if (customAttribute is DynamicReadOnlyAttribute)
                {
                    attributeList.RemoveAll(x => x is ReadOnlyAttribute);

                    if (DynamicReadOnlyAttribute.IsDynamicReadOnly(propertyObject, e.Property.Name))
                    {
                        //condition is true: the dynamic attribute should be applied (as static attribute)
                        attributeList.Add(new ReadOnlyAttribute(true)); //add static read only attribute
                    }
                }
            }
            
            e.Property.Attributes = attributeList.ToArray();

            var propertyInfo = propertyObject.GetType().GetProperty(e.Property.Name);
            var value = propertyInfo.GetValue(propertyObject, null);

            var isNestedPropertiesObject = IsNestedExpandablePropertiesObject(propertyInfo);

            // if nested properties object, wrap in DynamicPropertyBag to provide support for things like DynamicReadOnly
            e.Value = isNestedPropertiesObject ? new DynamicPropertyBag(value) : value;
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:32,代码来源:DynamicPropertyBag.cs

示例15: DataListTO

        public DataListTO(string dataList, bool ignoreColumnDirection = false)
        {
            var fixedDataList = dataList.Replace(GlobalConstants.SerializableResourceQuote, "\"").Replace(GlobalConstants.SerializableResourceSingleQuote, "\'");
            Inputs = new List<string>();
            Outputs = new List<string>();
            using (var stringReader = new StringReader(fixedDataList))
            {
                var xDoc = XDocument.Load(stringReader);

                var rootEl = xDoc.Element("DataList");

                if (rootEl != null)
                {
                    if (ignoreColumnDirection)
                    {
                        Map(rootEl);
                    }
                    else
                    {
                        MapForInputOutput(rootEl);
                    }
                }
            }
            Inputs.RemoveAll(string.IsNullOrEmpty);
            Outputs.RemoveAll(string.IsNullOrEmpty);
        }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:26,代码来源:DataListTO.cs


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