c# add item to list code example
Example 1: how to add data in list in c#
List<geo_tag> abc = new List<geo_tag>();
geo_tag tag = new geo_tag();
tag.latitude = 111;
tag.longitude = 122;
tag.unit = "SSS";
abc.Add(tag);
Example 2: add object to list c#
List<Author> authors = new List<Author>
{
new Author { Name = "Mahesh Chand", Book = "ADO.NET Programming", Price = 49.95 },
new Author { Name = "Neel Beniwal", Book = "Jump Ball", Price = 19.95 },
new Author { Name = "Chris Love", Book = "Practical PWA", Price = 29.95 }
};
authors.Add(new Author { Name = "Mahesh Chand", Book = "Graphics with GDI+", Price = 49.95 });
authors.Add(new Author { Name = "Mahesh Chand", Book = "Mastering C#", Price = 54.95 });
authors.Add(new Author { Name = "Mahesh Chand", Book = "Jumpstart Blockchain", Price = 44.95 });
Example 3: how to add to a list c#
var list = new List<string>();
list.Add("Hello");
Example 4: c# adding to a list
List<string> test = new List<string>();
test.Add("Hello")
Example 5: c# add list to list
List<string> initialList = new List<string>();
List<string> listToAdd = new List<string>();
initialList.AddRange(listToAdd);