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


C# List.RemoveRange方法代码示例

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


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

示例1: CreateInputBytes

		List<byte> CreateInputBytes(List<byte> messageBytes)
		{
			var bytes = new List<byte>();
			var previousByte = new byte();
			messageBytes.RemoveRange(0, messageBytes.IndexOf(0x7E) + 1);
			messageBytes.RemoveRange(messageBytes.IndexOf(0x3E), messageBytes.Count - messageBytes.IndexOf(0x3E));
			foreach (var b in messageBytes)
			{
				if ((b == 0x7D) || (b == 0x3D))
				{ previousByte = b; continue; }
				if (previousByte == 0x7D)
				{
					previousByte = new byte();
					if (b == 0x5E)
					{ bytes.Add(0x7E); continue; }
					if (b == 0x5D)
					{ bytes.Add(0x7D); continue; }
				}
				if (previousByte == 0x3D)
				{
					previousByte = new byte();
					if (b == 0x1E)
					{ bytes.Add(0x3E); continue; }
					if (b == 0x1D)
					{ bytes.Add(0x3D); continue; }
				}
				bytes.Add(b);
			}
			return bytes;
		}
开发者ID:saeednazari,项目名称:Rubezh,代码行数:30,代码来源:UsbHid.Comon.cs

示例2: TrimSilence

	public static AudioClip TrimSilence(List<float> samples, float min, int channels, int hz, bool _3D, bool stream) {
		int i;
 
		// remove samples at the beginning
		for (i=0; i<samples.Count; i++) {
			if (Mathf.Abs(samples[i]) > min) {
				break;
			}
		} 
		samples.RemoveRange(0, i);

		// sanity check
		if ( samples.Count != 0 )
		{ 
			// remove samples at the end
			for (i=samples.Count - 1; i>0; i--) {
				if (Mathf.Abs(samples[i]) > min) {
					break;
				}
			}
			samples.RemoveRange(i, samples.Count - i);
			UnityEngine.Debug.Log ("SaveWav.TrimSilence() samples after begin trim = " + samples.Count);
		}
		else
			UnityEngine.Debug.Log ("SaveWav.TrimSilence() no samples!");

		var clip = AudioClip.Create("TempClip", samples.Count, channels, hz, _3D, stream);
 
		if ( samples.Count != 0 )
			clip.SetData(samples.ToArray(), 0);

		return clip;
	}
开发者ID:MedStarSiTEL,项目名称:UnityTrauma,代码行数:33,代码来源:SaveWav.cs

示例3: Last

 private static void Last(List<int> array, string p1, string p2)
 {
     int count = int.Parse(p1);
     if (count > array.Count)
     {
         Console.WriteLine("Invalid count");
     }
     else
     {
         List<int> temp = new List<int>();
         if (p2 == "odd")
         {
             temp = array.Where(x => x % 2 == 1).ToList();
             if (count < temp.Count)
             {
                 temp.RemoveRange(0, temp.Count - count);
             }
             Console.WriteLine("[{0}]", string.Join(", ", temp));
         }
         else
         {
             temp = array.Where(x => x % 2 == 0).ToList();
             if (count < temp.Count)
             {
                 temp.RemoveRange(0, temp.Count - count);
             }
             Console.WriteLine("[{0}]", string.Join(", ", temp));
         }
     }
 }
开发者ID:psdimitrov,项目名称:homeworks,代码行数:30,代码来源:ArrayManipulator.cs

示例4: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            license = richTextBox1.Lines;
            IEnumerable<string> files = Directory.GetFiles (folder, textBox1.Text, SearchOption.AllDirectories);
            foreach (string file in files)
            {
                List<string> newLines = new List<string> ();
                newLines.AddRange (license);
                string[] lines = File.ReadAllLines (file);

                if (lines[0].StartsWith ("/*"))
                {
                    int endLine = 0;
                    for (int i = 0; i < lines.Length; i++)
                    {
                        if (lines[i].StartsWith (" */"))
                        {
                            endLine = i;
                            break;
                        }
                    }
                    List<string> l = new List<string>(lines);
                    l.RemoveRange(0, endLine + 1);
                    if (l[0] == "")
                        l.RemoveRange (0, 1);
                    newLines.AddRange (l);
                }
                else
                {
                    newLines.AddRange (lines);
                }
                File.WriteAllLines (file, newLines.ToArray ());
            }
        }
开发者ID:RevolutionSmythe,项目名称:License-Header-Applier,代码行数:34,代码来源:Form1.cs

示例5: DeclareVariable

        /// <summary>
        /// Declares a variable if there is a declaration and deletes unnessesary stuff
        /// </summary>
        /// <param name="listE"> stream of tokens </param>
        /// <returns> true if we need to launch the function again </returns>
        public static bool DeclareVariable(List<Element> listE)
        {
            if (listE.Count > 2) // it can be a declaration only if the list has more than 2 elements
            {
                if (listE[0].Type == C.Number && listE[1].Type == C.Control) // if it is a number
                {
                    string name = listE[0].GetNumber().Name;
                    if (name != "" && listE[1].ToString() == "=") // if it is a variable
                    {
                        listE.RemoveRange(0, 2);
                        Number num = new Number(Parse(listE).Value.ToString());
                        num.Name = name;
                        Variable.Add(num);

                        return false;
                    }
                }
            }

            int index = listE.FindIndex(delegate(Element e)
                                        { if (e.ToString() == "=") return true; return false; });
            if (index != -1) { listE.RemoveRange(0, index + 1); return true; }

            return false;
        }
开发者ID:jakl,项目名称:hashite,代码行数:30,代码来源:Parser.cs

示例6: Main

    static void Main()
    {
        string s;
        int inputLines = int.Parse(Console.ReadLine());
        int desiredWidth = int.Parse(Console.ReadLine());
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < inputLines; i++)
        {
            s = Console.ReadLine();
            sb.Append(s.Trim() + " ");
        }
        sb.Remove(sb.Length - 1, 1);
        string[] sWords = sb.ToString().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        List<string> words = new List<string>(sWords);
        do
        {

            sb.Clear();
            sb.Append(words[0]);
            int currentWord = 1;
            while (sb.Length < desiredWidth && currentWord < words.Count)
            {
                sb.Append(" " + words[currentWord]);
                currentWord++;
            }
            if (sb.Length > desiredWidth)
            {
                sb.Remove(sb.Length - words[currentWord - 1].Length - 1, words[currentWord - 1].Length + 1);
                currentWord--;
            }
                if (sb.Length == desiredWidth || currentWord == 1)
            {
                Console.WriteLine(sb);
                words.RemoveRange(0, currentWord);
                continue;
            }
            int spacecount = currentWord - 1;
            int sizeOfSpaces = (desiredWidth - sb.Length + spacecount) / spacecount; // / (currentWord - 1)
            int numOfLongSpaces = (desiredWidth - sb.Length + spacecount) % spacecount;
            sb.Clear();
            sb.Append(words[0]);
            for (int i = 1; i <= spacecount; i++)
            {
                if (i <= numOfLongSpaces)
                    sb.Append(" ");
                sb.Append(new string(' ',sizeOfSpaces) + words[i]);
            }
            Console.WriteLine(sb);
            words.RemoveRange(0, currentWord);
        } while (words.Count > 0);
    }
开发者ID:TheOldMan66,项目名称:TelerikAcademy,代码行数:51,代码来源:ConsoleJustification.cs

示例7: CreateDataShapeObject

        public object CreateDataShapeObject(DTO.ExpenseGroup expenseGroup, List<string> lstFields)
        {
            List<string> lstFieldsIncluded = new List<string>(lstFields);

            if (!lstFieldsIncluded.Any())
            {
                return expenseGroup;
            }
            else
            {
                var lstExpenseFields = lstFieldsIncluded.Where(s => s.Contains("expenses")).ToList();

                bool returnPartialExpense = lstFieldsIncluded.Any() && !lstFieldsIncluded.Contains("expenses");

                if (returnPartialExpense)
                {
                    lstFieldsIncluded.RemoveRange(lstExpenseFields);
                    lstExpenseFields = lstExpenseFields.Select(f => f.Substring(f.IndexOf(".") + 1)).ToList();
                }
                else
                {
                    lstExpenseFields.Remove("expenses");
                    lstFieldsIncluded.RemoveRange(lstExpenseFields);
                }


                ExpandoObject objToReturn = new ExpandoObject();
                foreach (var field in lstFieldsIncluded)
                {
                    var fieldValue = expenseGroup.GetType()
                        .GetProperty(field, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance)
                        .GetValue(expenseGroup, null);

                    ((IDictionary<string, object>)objToReturn).Add(field, fieldValue);
                }

                if(returnPartialExpense)
                {
                    List<object> expenses = new List<object>();
                    foreach(var expense in expenseGroup.Expenses)
                    {
                        expenses.Add(expenseFactory.CreateDataShapeObject(expense, lstExpenseFields));
                    }
                    ((IDictionary<string, object>)objToReturn).Add("expenses", expenses);
                }

                return objToReturn;
            }
        }
开发者ID:bkcrux,项目名称:WebAPIDemo,代码行数:49,代码来源:ExpenseGroupFactory.cs

示例8: proc

        private void proc(List<int> Input, int step)
        {
            if (Input.Count < 1 || SELECT - step > Input.Count)
                return;
            if (step == SELECT - 1)
            {
                foreach (var item in Input)
                {
                    result[step] = item;
                    //OutputToArray();
                    //tets
                    print(result);
                }
            }

            else
            {
                foreach (var item in Input)
                {
                    List<int> tempInput = new List<int>();
                    tempInput.AddRange(Input);
                    result[step] = item;
                    tempInput.RemoveRange(0, tempInput.IndexOf(item) + 1);
                    proc(tempInput, step + 1);
                }
            }
        }
开发者ID:juyingnan,项目名称:VS,代码行数:27,代码来源:Combination.cs

示例9: TrimSilence

	public static AudioClip TrimSilence(List<float> samples, float min, int channels, int hz, bool _3D, bool stream) {
		int i;

		for (i=0; i<samples.Count; i++) {
			if (Mathf.Abs(samples[i]) > min) {
				break;
			}
		}

		samples.RemoveRange(0, i);

		for (i=samples.Count - 1; i>0; i--) {
			if (Mathf.Abs(samples[i]) > min) {
				break;
			}
		}

		samples.RemoveRange(i, samples.Count - i);

		var clip = AudioClip.Create("TempClip", samples.Count, channels, hz, _3D, stream);

		clip.SetData(samples.ToArray(), 0);

		return clip;
	}
开发者ID:Omicron3141,项目名称:Coalition-Command,代码行数:25,代码来源:SavWav.cs

示例10: ZnajdzOtoczke

        public void ZnajdzOtoczke(List<Punkt> lista)
        {
            List<Punkt> listaTmp = new List<Punkt>();
            Stack stos = new Stack();

            stos.Push(lista[0]);
            stos.Push(lista[1]);
            stos.Push(lista[2]);

            listaTmp.Add(lista[0]);
            listaTmp.Add(lista[1]);
            listaTmp.Add(lista[2]);

            for (int i = 3; i < lista.Count; i++)
            {
                int j = i;
                while (ObliczDet(listaTmp[stos.Count - 2], listaTmp[stos.Count - 1], lista[i]) < 0)
                {
                    //Console.WriteLine(ObliczDet(lista[j - 2], lista[j - 1], lista[i]));
                    stos.Pop();
                    listaTmp.RemoveRange(stos.Count, 1);
                }
                stos.Push(lista[i]);
                listaTmp.Add(lista[i]);
            }
            int ileWierz = stos.Count;
            for (int i = 0; i < ileWierz; i++)
            {
                wierzcholki.Add((Punkt)stos.Pop());
            }
            wierzcholki.Reverse();
        }
开发者ID:krzSobin,项目名称:Algorytmy-projekt---Otoczka-wypukla-i-Monte-Carlo,代码行数:32,代码来源:Otoczka.cs

示例11: FilterResultsInInterval

 public void FilterResultsInInterval(DateTime dtStart, DateTime dtEnd, List<Object> list)
 {
     if (null == list) return;
     if (list.Count < 2) return;
     list.Sort();
     list.RemoveRange(1, list.Count - 1);
 }
开发者ID:erashid,项目名称:ScheduleTimer,代码行数:7,代码来源:ScheduleFilter.cs

示例12: Apply

    /// <summary>
    /// Joins all sub sub scopes of the given <paramref name="scope"/>, reduces the number of sub 
    /// scopes by 1 and uniformly partitions the sub sub scopes again, maintaining the order.
    /// </summary>
    /// <exception cref="InvalidOperationException">Thrown when there are less than 2 sub-scopes available or when VillageCount does not equal the number of sub-scopes.</exception>
    /// <param name="scope">The current scope whose sub scopes to reduce.</param>
    /// <returns><c>null</c>.</returns>
    public override IOperation Apply() {
      IScope scope = ExecutionContext.Scope;
      if (VillageCountParameter.ActualValue == null) VillageCountParameter.ActualValue = new IntValue(scope.SubScopes.Count);
      int villageCount = VillageCountParameter.ActualValue.Value;
      if (villageCount <= 1)
        throw new InvalidOperationException(Name + ": Reunification requires 2 or more sub-scopes");
      if (villageCount != scope.SubScopes.Count)
        throw new InvalidOperationException(Name + ": VillageCount does not equal the number of sub-scopes");

      // get all villages
      List<IScope> population = new List<IScope>();
      for (int i = 0; i < villageCount; i++) {
        population.AddRange(scope.SubScopes[i].SubScopes);
        scope.SubScopes[i].SubScopes.Clear();
      }

      // reduce number of villages by 1 and partition the population again
      scope.SubScopes.RemoveAt(scope.SubScopes.Count - 1);
      villageCount--;
      int populationPerVillage = population.Count / villageCount;
      for (int i = 0; i < villageCount; i++) {
        scope.SubScopes[i].SubScopes.AddRange(population.GetRange(0, populationPerVillage));
        population.RemoveRange(0, populationPerVillage);
      }

      // add remaining individuals to last village
      scope.SubScopes[scope.SubScopes.Count - 1].SubScopes.AddRange(population);
      population.Clear();

      VillageCountParameter.ActualValue.Value = villageCount;

      return base.Apply();
    }
开发者ID:t-h-e,项目名称:HeuristicLab,代码行数:40,代码来源:SASEGASAReunificator.cs

示例13: Main

 static void Main(string[] args)
 {
     InitComplements();
       var seq = new List<byte[]>();
       var b = new Block { Count = -1 };
       Index line = Index.None, start = Index.None, end = Index.None;
       using (var r = new BinaryReader(Console.OpenStandardInput())) {
      using (var w = Console.OpenStandardOutput()) {
         while (b.Read(r) > 0) {
            seq.Add(b.Data);
            if (line.Pos < 0) line = b.IndexOf(Gt, 0);
            while (line.Pos >= 0) {
               if (start.Pos < 0) {
                  var off = line.InBlock(b) ? line.Pos : 0;
                  start = b.IndexOf(Lf, off);
                  if (start.Pos < 0) {
                      w.Write(b.Data, off, b.Data.Length - off);
                      seq.Clear(); break;
                  }
                  w.Write(b.Data, off, start.Pos + 1 - off);
               }
               if (end.Pos < 0) {
                  end = b.IndexOf(Gt, start.InBlock(b) ? start.Pos : 0);
                  if (end.Pos < 0) break;
               }
               w.Reverse(start.Pos, end.Pos, seq);
               if (seq.Count > 1) seq.RemoveRange(0, seq.Count - 1);
               line = end; end = Index.None; start = Index.None;
            }
         }
         if (start.Pos >= 0 && end.Pos < 0)
            w.Reverse(start.Pos, seq[seq.Count -1].Length, seq);
      }
       }
 }
开发者ID:kjk,项目名称:kjkpub,代码行数:35,代码来源:revcomp.cs

示例14: Adjust_score_for_frame_11

        private static void Adjust_score_for_frame_11(List<int> frameScores)
        {
            if (frameScores.Count <= 10) return;

            frameScores.RemoveRange(10, frameScores.Count() - 10);
            frameScores.Add(0);
        }
开发者ID:ralfw,项目名称:dnp2013,代码行数:7,代码来源:Scorer.cs

示例15: ASCommandResponse

        public ASCommandResponse(HttpWebResponse httpResponse)
        {
            httpStatus = httpResponse.StatusCode;

            Stream responseStream = httpResponse.GetResponseStream();
            List<byte> bytes = new List<byte>();
            byte[] byteBuffer = new byte[256];
            int count = 0;

            // Read the WBXML data from the response stream
            // 256 bytes at a time.
            count = responseStream.Read(byteBuffer, 0, 256);
            while (count > 0)
            {
                // Add the 256 bytes to the List
                bytes.AddRange(byteBuffer);

                if (count < 256)
                {
                    // If the last read did not actually read 256 bytes
                    // remove the extra.
                    int excess = 256 - count;
                    bytes.RemoveRange(bytes.Count - excess, excess);
                }

                // Read the next 256 bytes from the response stream
                count = responseStream.Read(byteBuffer, 0, 256);
            }

            wbxmlBytes = bytes.ToArray();

            // Decode the WBXML
            xmlString = DecodeWBXML(wbxmlBytes);
        }
开发者ID:MishaKharaba,项目名称:ExchangeActiveSync,代码行数:34,代码来源:ASCommandResponse.cs


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