



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




int[] arr = {1,2,3}; List list = new List(); list.Add(1);
list.Add(2); d) How do you make a property read-only?
public class Student { public string Name { get; } public Student(string name) { Name = name; } }
public int Age { get; private set; } e) Difference between Func, Action and Predicate delegates Action
C - Length: 1 Sharp - Length: 5 is - Length: 2 a - Length: 1 powerful - Length: 8 programming - Length: 11 language - Length: 8
using System; using System.Collections.Generic; class Program { static void Main() { Dictionary> provinces = new Dictionary>(); provinces["Punjab"] = new List { "Lahore", "Rawalpindi", "Faisalabad", "Multan", "Bahawalpur", "Rahim Yar Khan", "Sargodha", "Gujranwala", "Gujrat" }; provinces["KPK"] = new List { "Peshawar", "Mardan", "DI Khan", "Abbottabad", "Kohat", "Bannu", "Swat" }; provinces["Balochistan"] = new List { "Quetta", "Gwadar", "Zhob", "Sibi", "Turbat"
provinces["Sindh"] = new List { "Karachi", "Hyderabad", "Sukkur", "Nawab Shah", "Sadiq Abad" }; foreach (KeyValuePair> province in provinces) { Console.WriteLine(province.Key); foreach (string city in province.Value) { Console.Write(city + ", "); } Console.WriteLine("\n"); } } } Expected Output Punjab Lahore, Rawalpindi, Faisalabad, Multan, Bahawalpur, Rahim Yar Khan, Sargodha, Gujranwala, Gujrat KPK Peshawar, Mardan, DI Khan, Abbottabad, Kohat, Bannu, Swat Balochistan Quetta, Gwadar, Zhob, Sibi, Turbat Sindh Karachi, Hyderabad, Sukkur, Nawab Shah, Sadiq Abad