Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8910707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:45:27+00:00 2026-06-15T03:45:27+00:00

I found below code by web search and I don’t understand why the author

  • 0

I found below code by web search and I don’t understand why the author uses the enum in that class. Is it for value limitation? Is it so WhichSex can take only ‘Male’ and ‘Female’ string values?

public class Person
{
   public enum Sex
   {
      Male,
      Female,
   }
   public string Name { get; set; }
   public bool Moustache { get; set; }
   public bool Goatee { get; set; }
   public bool Beard { get; set; }
   public Sex WhichSex { get; set; }
   public double Height { get; set; }
   public DateTime BirthDate { get; set; }
   public bool Favorite { get; set; }     
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T03:45:28+00:00Added an answer on June 15, 2026 at 3:45 am

    The enum is used as a way of representing numeric data in a way that is more easily recognized in programming.

    Behind the enum, is an integer datatype seeded starting at zero, so in this case Male is 0 and Female is 1. This allows you to have the strings Male and Female in your code while storing the result as an integer instead of a string which is easier on storage and bandwidth.

    The reason for the enum here is simple. They can ToString it and get the strings “Male” or “Female” for reporting, and they can also add another value for “unknown” or “not specified” later down the road if needed.

    http://msdn.microsoft.com/en-us/library/sbbt4032%28v=vs.80%29.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found the below code in the Internet, I'm trying to understand how Linux
I've found the piece of code below in several places around the web and
The code below uses an octahedron as a starting 3D shape, ( I found
The code below uses an octahedron as a starting 3D shape, ( I found
I'm currently using the code below found on web tutorial to show/hide DIVs. It
I found this orientation test code below looking for JQTouch reference material. This works
I found one piece of sample code from web forum. When I began to
I found some code on the web and it threw me off. Look at
i found the code below in stackoverflow for resumeable file downloads : using System;
From this tutorial http://www.brighthub.com/internet/web-development/articles/11010.aspx I found the code below. Is there a way to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.