Dictionary<TKey, TValue>.Keys প্রোপার্টি কীগুলোর কালেকশন রিটার্ন করে। এটি List<TKey> কনস্ট্রাক্টরে পাস করে কীগুলোর লিস্ট তৈরি করা যায়।
উদাহরণ
using System;
using System.Collections.Generic;
public class Demo {
public static void Main() {
var dict = new Dictionary {
{1, "One"}, {2, "Two"}, {3, "Three"}, {4, "Four"},
{5, "Five"}, {6, "Six"}, {7, "Seven"}, {8, "Eight"}
};
List keys = new List(dict.Keys);
foreach (int k in keys) Console.WriteLine(k);
}
}
আউটপুট
1 2 3 4 5 6 7 8