static void Main(string[] args) { string name = "ankit"; int age = 28; int salary = 50; Console.WriteLine($"Name : {name}, Age: {age}, Salary: {salary}"); List <Artist> artists = new List <Artist> { new Artist { Name = "ankit", Age = 28 }, new Artist { Name = "Anu", Age = 25 } }; int?count = artists?.Count ?? 0; Console.WriteLine($"Count is :{count}"); Artist defArtist = artists?[0]; Console.WriteLine($"Default artist: { defArtist?.Name}, Age: {artists?[0]?.Age}"); var array = new[] { "Name", "ArtistType" }; var thisArrayList = new List <string>(array) { [0] = "Ankit", [1] = "mafia" }; var ArtistCollection = new ArtistCollection { new Artist { Name = "rahul", Age = 27 }, new Artist { Name = "rohan", Age = 27 } }; foreach (var item in ArtistCollection) { Console.WriteLine($"{item?.Name} is {item?.Age} years old"); } Console.ReadKey(); }
public static Artist Add(this ArtistCollection collection, Artist anotherArtist) { collection.Put(anotherArtist); return(anotherArtist); }