C#
C# Database Connection: How to connect SQL Server (Example)
Accessing Data from a database is one of the important aspects of any programming language. It is...
An enumeration is used in any programming language to define a constant set of values. For example, the days of the week can be defined as an enumeration and used anywhere in the program. In C#, the enumeration is defined with the help of the keyword 'enum'.
Let's see an example of how we can use the 'enum' keyword.
In our example, we will define an enumeration called days, which will be used to store the days of the week. For each example, we will modify just the main function in our Program.cs file.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DemoApplication
{
class Program
{
enum Days{Sun,Mon,tue,Wed,thu,Fri,Sat};
static void Main(string[] args)
{
Console.Write(Days.Sun);
Console.ReadKey();
}
}
}If the above code is entered properly and the program is executed successfully, the following output will be displayed.
From the output, you can see that the 'Sun' value of the enumeration is displayed in the console.
Accessing Data from a database is one of the important aspects of any programming language. It is...
C# is based on the C++ programming language. Hence, the C# programming language has in-built...
What is Queue in C#? The Queue is a special case collection which represents a first in first out...
In our previous tutorial, we have learned about how we can use arrays in C#. Let's have a quick...
C-SHARP (C#) is a general-purpose, multi-paradigm programming language developed by Microsoft that runs...
$20.20 $9.99 for today 4.5 (114 ratings) Key Highlights of C# Tutorial PDF 243+ pages eBook...