Add places an element at the end of a List.
Above statement is given in the following website. What is meant by "end of a List"? Problem is highlighted.
http://www.dotnetperls.com/list-add
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Posted Sep 10, 2013, 6:21 PM
VulpesPosted Sep 10, 2013, 6:01 PM
Posted Sep 10, 2013, 4:52 PM
a = 1 b = 2
a = 3 b = 4
a = 5 b = 6
using System;
using System.Collections.Generic;
class Program
{
static void Main()
{
// Add three objects to a List.
List
list.Add(new Test(1, 2));
list.Add(new Test(3, 4));
list.Add(new Test(5, 6));
Console.WriteLine("a = {0} b = {1}", list.getNumberA(), list.getNumberB());
}
class Test
{
int a;
int b;
public Test(int a, int b)
{
this.a = a;
this.b = b;
}
public int getNumberA()
{
return a;
}
public int getNumberB()
{
return b;
}
}
}
Posted Sep 10, 2013, 11:22 AM
VulpesPosted Sep 10, 2013, 11:12 AM
As well as adding elements to a List