একটি নির্দিষ্ট গণনায় ধ্রুবকের মানের অ্যারে পান।
এখানে আমাদের enum.
enum Rank { Jack = 10, Tom = 19, Tim = 26 }; এখন, একটি অ্যারে হিসাবে enum এর সমস্ত মান পান এবং GetValues() পদ্ধতি ব্যবহার করে প্রদর্শন করুন৷
foreach(int res in Enum.GetValues(typeof(Rank))) {
Console.WriteLine(res);
} আসুন পুরো উদাহরণটি দেখি।
উদাহরণ
using System;
public class Demo {
enum Rank { Jack = 10, Tom = 19, Tim = 26 };
public static void Main() {
Console.WriteLine("Here are the university rank of MCA Students College ABC:");
foreach(int res in Enum.GetValues(typeof(Rank))) {
Console.WriteLine(res);
}
}
} আউটপুট
Here are the university rank of MCA Students College ABC: 10 19 26