Quick way to add items in collection
below is the example
below is the example
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication7
{
public class Person
{
private string _firstName;
public string firstName{get { return _firstName; }set { _firstName = value;} }
}
class Program
{
static void Main(string[] args)
{
List<Person> obj=new List<Person>
{
new Person {firstName ="ABC"},
new Person {firstName ="Test"}
};
foreach (Person p in obj)
{
Console.WriteLine(p.firstName);
}
}
}
}
Great example... Power of collections!
ReplyDelete