Here's an example program that demonstrates the use of C# enums and gender types:
using System; namespace GenderEnumExample { enum Gender { Male, Female, NonBinary } class Program { static void Main(string[] args) { Gender userGender; Console.WriteLine("Please enter your gender (M/F/NB): "); string userInput = Console.ReadLine(); if (userInput == "M") { userGender = Gender.Male; } else if (userInput == "F") { userGender = Gender.Female; } else if (userInput == "NB") { userGender = Gender.NonBinary; } else { Console.WriteLine("Invalid input."); return; } Console.WriteLine("Your gender is: " + userGender); } } }In this program, we define an enum called Gender, which has three possible values: Male, Female, and NonBinary. We then use this enum to store the user's input and print out their gender.
First, we prompt the user to enter their gender (using the abbreviations M, F, or NB). We then check the user's input against each possible value and assign the corresponding enum value to the userGender variable. If the user enters an invalid input, we print an error message and exit the program.
Finally, we print out the user's gender using the Console.WriteLine() method.