static void Main() { // Declare a list of type int SomeList<int> intList = new SomeList<int>(); intList.Add(1); intList.Add(2); intList.Add(3); Console.WriteLine("Number of elements: {0}", intList.Count); for (int i = 0; i < intList.Count; i++) { int element = intList[i]; Console.WriteLine(element); } Console.WriteLine(); // Declare a list of type string SomeList<string> stringList = new SomeList<string>(); stringList.Add("C#"); stringList.Add("Java"); stringList.Add("PHP"); stringList.Add("SQL"); Console.WriteLine("Number of elements: {0}", stringList.Count); for (int i = 0; i < stringList.Count; i++) { string element = stringList[i]; Console.WriteLine(element); } }
public void OnEnteredTextChanged(string value) { LabelColor = (LabelColor == null) ? Color.Gray : (Color?)null; SomeDouble = 0.1d * (value?.Length ?? 0); SomeList = SomeList ?? new List <int>(); SomeList.Add(SomeList.Count); }
public void IterateOverCharList() { var list = new SomeList(new List <int> { 9, 3, 6 }); // storing results just for demo var result = list.IterateOverData(); Assert.That(result, Is.EqualTo("936")); new GlobalPrinter().PrintData(list.GetData()); }
public void Enumerables() { var actual = new SomeList <int> { 1, 2, 3 }.ToStringReflection(); const string expected = "SomeList`1@16 [\n" + " 1,\n" + " 2,\n" + " 3,\n" + "]"; Assert.AreEqual(expected, actual); }
public void EnumerableWithNull() { var actual = new SomeList <object> { new ClassWithToString(), null }.ToStringReflection(); const string expected = "SomeList`1@16 [\n" + " {\n" + " XYZ\n" + " },\n" + " null,\n" + "]"; Assert.AreEqual(expected, actual); }
public void SerializeNestedList() { var list1 = new SomeList() { new ListItem("aaa"), new ListItem("bbb") }; var list2 = new SomeList() { new ListItem("ccc"), new ListItem("ddd") }; var nestedList = new NestedList(); nestedList.Add(list1); nestedList.Add(list2); Serializer.Serialize(Stream.Null, nestedList); }
public void RecursionPrevensionInEnumerables() { var someList = new SomeList <object>(); var sut = new ClassWithNesting { HashCode = 1, Nested = someList }; someList.Add(sut); var actual = sut.ToStringReflection(); const string expected = "ClassWithNesting@1 {\n" + " HashCode = 1,\n" + " Nested = SomeList`1@16 [\n" + " {--> ClassWithNesting@1},\n" + " ],\n" + "}"; Assert.AreEqual(expected, actual); }
public Production(SomeList <T> obj) { this.obj = obj; }