how to add data in list in csharp
Code Example - how to add data in list in csharp
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);
add object to list csharp
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 }
};
// Add more items to the list
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 });
csharp adding to a list
//Declaring that its a list
List<string> test = new List<string>();
test.Add("Hello")
c list add element
// Create a list
List<string> AuthorList = new List<string>();
// Add items using Add method
AuthorList.Add("Mahesh Chand");
how to add to a list csharp
var list = new List<string>();
list.Add("Hello");
csharp add list to list
using System;
using System.Collections.Generic;
namespace add_list
{
static void Main(string[] args)
{
List<string> first = new List<string> { "do", "rey", "me" };
List<string> second = new List<string> { "fa", "so", "la", "te" };
first.AddRange(second);
foreach(var e in first)
{
Console.WriteLine(e);
}
}
}
}
how to add to a list in csharp
List<string> names = new List<string>();
names.Add("Bob");