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

  • SEARCH
  • Home
  • 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 50341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T16:34:41+00:00 2026-05-10T16:34:41+00:00

I have an enum that looks as follows: public enum TransactionStatus { Open =

  • 0

I have an enum that looks as follows:

public enum TransactionStatus { Open = 'O', Closed = 'C'}; 

and I’m pulling data from the database with a single character indicating – you guessed it – whether ‘O’ the transaction is open or ‘C’ the transaction is closed.

now because the data comes out of the database as an object I am having a heck of a time writing comparison code.

The best I can do is to write:

protected bool CharEnumEqualsCharObj(TransactionStatus enum_status, object obj_status) {     return ((char)enum_status).ToString() == obj_status.ToString(); } 

However, this is not the only character enum that I have to deal with, I have 5 or 6 and writting the same method for them is annoying to say the least. Supposedly all enums inherit from System.Enum but if I try to set that as the input type I get compilation errors. This is also in .NET 1.1 so generics are out of the question.

I’ve been struggling with this for a while. Does anyone have a better way of writing this method? Also, can anyone clarify the whole enums inherit from System.Enum but are not polymorphic thing?

  • 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. 2026-05-10T16:34:42+00:00Added an answer on May 10, 2026 at 4:34 pm
    static void Main(string[] args) {     object val = 'O';     Console.WriteLine(EnumEqual(TransactionStatus.Open, val));      val = 'R';     Console.WriteLine(EnumEqual(DirectionStatus.Left, val));      Console.ReadLine(); }  public static bool EnumEqual(Enum e, object boxedValue) {                             return e.Equals(Enum.ToObject(e.GetType(), (char)boxedValue)); }  public enum TransactionStatus { Open = 'O', Closed = 'C' }; public enum DirectionStatus { Left = 'L', Right = 'R' }; 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a c# enumeration that looks like this: public enum EthernetLinkSpeed { [Description(10BASE-T)]
I have an enum that looks a little bit like this: public enum Numbers
I have a source object that looks like this: private class SourceObject { public
I have an enum, that looks like this: enum Suit {Clubs, Diamonds, Hearts, Spades};
I have some C++ code that looks like this: enum { FOO = 0x01,
I have a piece of C# code that add the values of an enum
I have an enum construct like this: public enum EnumDisplayStatus { None = 1,
I have an Enum called Status defined as such: public enum Status { VALID(valid),
I have a Enum for example... public enum TypeIdentifier { NotSet = 0, Type1=
I have an enum public enum FileExtentions { mp3, mpeg } And I have

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.