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 7972349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:50:24+00:00 2026-06-04T07:50:24+00:00

I have a struct that I am trying to use like an enum: public

  • 0

I have a struct that I am trying to use like an enum:

public struct SQLDS_statementTypes
{
    public static string Select = "Select", 
        Update = "Update", Insert = "Insert", Delete = "Delete";
}

But it throw an error: “Operator ‘==’ cannot be applied to operands of type ‘SQLDS_statementTypes’ and ‘string'” on this statement:

if (statement == SQLDS_statementTypes.Update)

Is there anyway to solve this?

  • 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-04T07:50:25+00:00Added an answer on June 4, 2026 at 7:50 am

    Someone was looking for something that seems more or less what you’re looking for a while back (I can’t be bothered to find a link) and I wrote this at the time. You may want to change the class name to be more inline with what you want. I hope that the configurations for adding/removing values are straightforward, if not I can elaborate.

    public struct Group
    {
        #region Code that is to be configured
        public static readonly Group Alpha = new Group("Group Alpha");
        public static readonly Group Beta = new Group("Group Beta");
        public static readonly Group Invalid = new Group("N/A");
    
    
        public static IEnumerable<Group> AllGroups
        {
            get
            {
                yield return Alpha;
                yield return Beta;
                yield return Invalid;
                //...
                //add a yield return for all instances here.
            }
        }
    
        #endregion
        private string value;
    
        /// <summary>
        /// default constructor
        /// </summary>
        //private Group()
        //{
        //    //you can make this default value whatever you want.  null is another option I considered, but you 
        //    //shouldn't have this me anything that doesn't exist as one of the options defined at the top of 
        //    //the page.
        //    value = "N/A";
        //}
        /// <summary>
        /// primary constructor
        /// </summary>
        /// <param name="value">The string value that this is a wrapper for</param>
        private Group(string value)
        {
            this.value = value;
        }
    
        /// <summary>
        /// Compares the Group to another group, or to a string value.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            if (obj is Group)
            {
                return this.value.Equals(((Group)obj).value);
            }
    
            string otherString = obj as string;
            if (otherString != null)
            {
                return this.value.Equals(otherString);
            }
    
            throw new ArgumentException("obj is neither a Group nor a String");
        }
    
        public override int GetHashCode()
        {
            return value.GetHashCode();
        }
    
        /// <summary>
        /// returns the internal string that this is a wrapper for.
        /// </summary>
        /// <param name="group"></param>
        /// <returns></returns>
        public static implicit operator string(Group group)
        {
            return group.value;
        }
    
        /// <summary>
        /// Parses a string and returns an instance that corresponds to it.
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public static Group Parse(string input)
        {
            return AllGroups.Where(item => item.value == input).FirstOrDefault();
        }
    
        /// <summary>
        /// Syntatic sugar for the Parse method.
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        public static explicit operator Group(string other)
        {
            return Parse(other);
        }
    
        public override string ToString()
        {
            return value;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a struct that looks something like this: [StructLayout(LayoutKind.Sequential)] public struct in_addr {
I have a struct that I initialize like this: typedef struct { word w;
I have a struct that's defined like this: struct Vec3 { float x, y,
I have a struct that looks like this: typedef struct _my_struct { float first_vector[SOME_NUM][OTHER_NUM];
Let's say I have a struct that contains local environments: public struct Environments {
I have an unmanaged struct I'd like to marshal to c sharp that looks
I am trying to create a struct that has multiple string arrays inside of
Say I have a struct declared like the following: public struct Test { public
I have a struct-array that contains details of different reports that can be run.
I have a 3rd party struct that is comprised of the following: [StructLayout(LayoutKind.Sequential, Size=1)]

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.