Thanks for reading my article first. C# program to demonstrate the use of Format() method of Enum class We are going to learn more about this in this article. Let’s go into the article

C# program to demonstrate the use of Format() method of Enum class
using System;
class Sample
{
enum Color { RED=0,GREEN=1,YELLOW=3,WHITE=4,BLACK=5};
//Entry point of Program
static public void Main()
{
Color firstColor = Color.GREEN;
Color secondColor = Color.WHITE;
string strValue = "";
strValue = Enum.Format(typeof(Color), firstColor, "d");
Console.WriteLine(strValue);
strValue = Enum.Format(typeof(Color), secondColor, "x");
Console.WriteLine(strValue);
}
}
1
00000004
Press any key to continue . . .
Final Words
C# program to demonstrate the use of Format() method of Enum class We hope this article solves all your doubts. If in doubt let me know.