本文整理汇总了C#中Queue.WhereNot方法的典型用法代码示例。如果您正苦于以下问题:C# Queue.WhereNot方法的具体用法?C# Queue.WhereNot怎么用?C# Queue.WhereNot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Queue
的用法示例。
在下文中一共展示了Queue.WhereNot方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
Queue<int> queue = new Queue<int>();
queue.Enqueue(2);
queue.Enqueue(10);
queue.Enqueue(5);
queue.Enqueue(6);
var resultQueue = queue.WhereNot(x => x % 3 == 0);
foreach (var item in resultQueue)
{
Console.WriteLine(item);
}
}
示例2: Main
static void Main(string[] args)
{
// This sample data is taken from the forum
Queue<int> queue = new Queue<int>();
queue.Enqueue(2);
queue.Enqueue(24);
queue.Enqueue(51);
queue.Enqueue(61);
queue.Enqueue(65);
queue.Enqueue(90);
queue.Enqueue(100);
var result = queue.WhereNot(x => x % 3 == 0);
foreach (var item in result)
{
Console.WriteLine(item);
}
List<int> numbers = new List<int>();
numbers.Add(3);
numbers.Add(4);
numbers.Add(5);
var allNumbers = numbers.Repeat(3);
Console.WriteLine();
foreach (var item in allNumbers)
{
Console.WriteLine(item);
}
Console.WriteLine();
List<string> words = new List<string>() { "Configuration", "hi", "cool", "full", "Hello", "how", "revolution", "commendation", "contrition", " starvation" };
List<string> suffixes = new List<string>() { "tion", "l" };
var filtredWords = words.WhereEndsWith(suffixes);
foreach (var item in filtredWords)
{
Console.WriteLine(item);
}
}
示例3: Main
public static void Main()
{
Queue<int> test=new Queue<int>();
for (int i = 0; i < 50; i++)
{
test.Enqueue(i);
}
var result = test.WhereNot(x => (x % 2) == 0);
Console.Write("Test WhereNot: ");
foreach(var item in result)
{
Console.Write(item);
}
Console.WriteLine();
var resultOne = test.Repeat(2);
Console.Write("Test Repeat: ");
foreach (var item in resultOne)
{
Console.Write(item);
}
Console.WriteLine();
Queue<string> names = new Queue<string>();
names.Enqueue("Petar");
names.Enqueue("Rusev");
names.Enqueue("Rusev");
Console.Write("Test WhereEndsWith: ");
List<string> suffixes=new List<string>();
suffixes.Add("v");
var resultTwo=names.WhereEndsWith(suffixes);
foreach (var item in resultTwo)
{
Console.Write("{0} ",item);
}
Console.WriteLine();
}