[C#] Storing different list types in a single generic list
페이지 정보
작성자 sbLAB 댓글 0건 조회 4,434회 작성일 18-07-25 17:36본문
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace genericLlist
{
class Program
{
static void Main(string[] args)
{
//Main object List
List<List<object>> list = new List<List<object>>();
//Each Sub list1
List<object> list1 = new List<object>();
list1.Add(101); list1.Add(102);
list.Add(list1);
//Each Sub list2
List<object> list2 = new List<object>();
list2.Add("string1"); list2.Add("string2");
list.Add(list2);
foreach (List<object> objectList in list)
{
foreach (object obj in objectList)
{
Console.WriteLine(obj);
}
Console.WriteLine();
}
}
}
}
- 이전글[C#] What is the difference between is and as keyword in c# 18.07.25
- 다음글[C#]Real time example of recursion 18.07.25
댓글목록
등록된 댓글이 없습니다.