本文整理汇总了C#中GenericList.Print方法的典型用法代码示例。如果您正苦于以下问题:C# GenericList.Print方法的具体用法?C# GenericList.Print怎么用?C# GenericList.Print使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GenericList
的用法示例。
在下文中一共展示了GenericList.Print方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
GenericList<int> list = new GenericList<int>();
list.Add(5);
list.Add(6);
list.Add(7);
list.Add(8);
Console.WriteLine(list.Min());
list.InsertAt(234, 2);
list.Print();
Console.WriteLine();
// Remove at index
list.RemoveAt(2);
list.Print();
Console.WriteLine();
// insert At
list.InsertAt(234, 2);
list.Print();
// find At
Console.WriteLine();
Console.WriteLine(list.FindAt(0));
// Test Find Method - using delagates ...
Console.WriteLine(list.Find(delegate(int value)
{
return value == 72;
}));
list.Clear();
list.Print();
// using attribute
Type type = typeof(TestGenericList);
object[] allAttributes = type.GetCustomAttributes(false);
foreach (VersionAttribute attr in allAttributes)
{
Console.WriteLine("Version of class TestGenericList is {0:0.00}",attr.Version);
}
}
示例2: Main
private static void Main()
{
GenericList<string> list = new GenericList<string>();
//adding an element
list.Add("0 - primeren");
list.Add("1 - listttt");
list.Add("2 - asfsdfsdfsdfd");
//accessing element by index
string s = list.AccessByIndex(1);
Console.WriteLine(s);
Console.WriteLine("------------------");
//removing element by index
list.RemoveAt(1);
list.Print();
Console.WriteLine("----------------");
//inserting element at given position
list.InsertAt("inserttttt", 2);
list.Print();
Console.WriteLine("-----------------");
//clearing the list
list.Clear();
//check if the list contains a value
list.Add("edno");
list.Add("dve");
list.Add("tri");
bool b = list.Contains("dve");
Console.WriteLine(b);
Console.WriteLine("---------------");
//print the entire list
list.Print();
Console.WriteLine("----------------");
//auto-grow
//GenericList<string> list3 = new GenericList<string>() { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17" };
//list3.Print();
//Console.WriteLine("-------------------");
GenericList<int> list4 = new GenericList<int> {1, 2, -3, 4, 50, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17};
list4.Print();
Console.WriteLine("--------");
//min
var min = list4.Min();
Console.WriteLine(min);
//max
var max = list4.Max();
Console.WriteLine(max);
Console.WriteLine("------------");
//Problem 4 - Generic List Version
Type type = typeof (GenericList<>);
object[] allAttributes = type.GetCustomAttributes(false);
foreach (VersionAttribute attr in allAttributes)
{
Console.WriteLine("Version: {0}", attr.Version);
}
}