本文整理汇总了C#中GenericList.Contain方法的典型用法代码示例。如果您正苦于以下问题:C# GenericList.Contain方法的具体用法?C# GenericList.Contain怎么用?C# GenericList.Contain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GenericList
的用法示例。
在下文中一共展示了GenericList.Contain方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
GenericList<int> arr = new GenericList<int>();
arr.Add(5);
arr.Add(6);
arr.InsertElement(3, 1);
arr.InsertElement(2, 4);
arr.Contain(5);
Console.WriteLine(arr.Contain(15));
Console.WriteLine(arr);
}
示例2: Main
static void Main()
{
var list = new GenericList<int> {10, 20, 30, 40};
Console.WriteLine("List Capacity: " + list.Capacity);
Console.WriteLine("List Count: " + list.Count);
Console.WriteLine(list);
Console.WriteLine();
Console.WriteLine("Add element (50) to the list");
list.Add(50);
Console.WriteLine(list);
Console.Write("get element on index 1: ");
Console.WriteLine(list[1]);
Console.WriteLine("remove element on index 1");
list.Remove(1);
Console.WriteLine(list);
Console.WriteLine("Insert element (200) on index 1");
list.Insert(200, 1);
Console.WriteLine(list);
Console.Write("finding element index by given value(200): ");
Console.WriteLine(list.Find(200));
Console.Write("finding element index by given value(500): ");
Console.WriteLine(list.Find(500));
Console.WriteLine();
Console.Write("checking if the list contains a value(200): ");
Console.WriteLine(list.Contain(200));
Console.Write("checking if the list contains a value(500): ");
Console.WriteLine(list.Contain(500));
Console.WriteLine();
Console.Write("find max number in list: ");
Console.WriteLine(list.Max());
Console.Write("find min number in list: ");
Console.WriteLine(list.Min());
Console.WriteLine();
Console.WriteLine("Clear list");
list.Clear();
Console.WriteLine(list);
Console.WriteLine("get Version Attribute of GenericList<T>: " + GetVersion());
;
}
示例3: Main
public static void Main()
{
var list = new GenericList<int> { 1, 2 };
Console.WriteLine(list);
list.Add(5);
Console.WriteLine(list);
var minElement = list.Min();
var maxElement = list.Max();
Console.WriteLine("min --> {0}", minElement);
Console.WriteLine("max --> {0}", maxElement);
list.Add(25);
Console.WriteLine(list);
list.Remove(1);
Console.WriteLine(list);
list.Insert(2, 16);
Console.WriteLine(list);
int index = list.Find(16);
Console.WriteLine("index --> {0}", index);
bool contains = list.Contain(5);
Console.WriteLine(contains);
contains = list.Contain(13);
Console.WriteLine(contains);
list.Clear();
Console.WriteLine(list);
Console.WriteLine();
object[] versionAttributes = typeof(GenericList<string>).GetCustomAttributes(false);
Console.WriteLine("Version --> {0}\n", versionAttributes[1]);
}