Suggested Videos:
Part 4 - What are the advantages of using interfaces
Part 5 - Recursive function c# example
Part 6 - Real time example of recursion
Yes, it is possible to store n number of lists of different types in a single generic list by creating a list of list of objects as shown below.
List<List<object>> list = new List<List<object>>();
Here is an example
public class Program
{
public static void Main()
{
List<List<object>> list = new List<List<object>>();
List<object> list1 = new List<object>();
list1.Add(101);
list1.Add(102);
list1.Add(103);
list.Add(list1);
List<object> list2 = new List<object>();();
list2.Add("Test1");
list2.Add("Test2");
list2.Add("Test3");
list.Add(list2);
foreach (List<object> objectList in list)
{
foreach (object obj in objectList)
{
Console.WriteLine(obj);
}
Console.WriteLine();
}
}
}
Part 4 - What are the advantages of using interfaces
Part 5 - Recursive function c# example
Part 6 - Real time example of recursion
Yes, it is possible to store n number of lists of different types in a single generic list by creating a list of list of objects as shown below.
List<List<object>> list = new List<List<object>>();
Here is an example
public class Program
{
public static void Main()
{
List<List<object>> list = new List<List<object>>();
List<object> list1 = new List<object>();
list1.Add(101);
list1.Add(102);
list1.Add(103);
list.Add(list1);
List<object> list2 = new List<object>();();
list2.Add("Test1");
list2.Add("Test2");
list2.Add("Test3");
list.Add(list2);
foreach (List<object> objectList in list)
{
foreach (object obj in objectList)
{
Console.WriteLine(obj);
}
Console.WriteLine();
}
}
}
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-ubJq7wEajd9irgQNLRUaihpS3wyX1-SPHecvY-IzrZ3ZZzI49qN32bI8t-XGmIIk-_syfT7raziZTbo6ak2NKuKGH5SUbdzpHslHxrcJIT2oHTm3T7J1Qgyv8y26WuXDaHUbpRisur2P/s1600/C%23+interview+questions.png)
Thankyou very much sir...
ReplyDeleteSir, Please post Lambda expression tutorial sir.