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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:06:10+00:00 2026-06-11T08:06:10+00:00

I have the following method and enum: public int GetRowType(string pk) { return Convert.ToInt32(pk.Substring(2,

  • 0

I have the following method and enum:

public int GetRowType(string pk) 
    {
        return Convert.ToInt32(pk.Substring(2, 2));
    }


public enum CONTENT {
    Menu = 0,
    Article = 1,
    FavoritesList = 2,
    ContentBlock = 3,
    Topic = 6,
    List = 7
};

Here I am trying to check if the result of my method is equal to the value of the enum but I am getting an error:

GetRowType(content) == CONTENT.Topic

Can someone give me some advice on what I am doing wrong?

Gives me an error: Error    2   
Operator '==' cannot be applied to operands of type 'int' and 'Storage.Constants.CONTENT'
  • 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-11T08:06:11+00:00Added an answer on June 11, 2026 at 8:06 am

    The whole idea is to work with the enum directly. so to fix up your method and return a enum instead of an integer:

    public CONTENT GetRowType(string pk) 
    {
        int temp = Convert.ToInt32(pk.Substring(2, 2));
        if (Enum.IsDefined(typeof(CONTENT), temp)) 
        { 
            return (CONTENT)temp;
        }
        else throw new IndexOutOfRangeException();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following method: public string Phase(string phase) { return Phase 1; }
I have the following method: public static T ExecuteScalar<T>( string query, SqlConnection connection, params
I have the following code: public int Method(MyEnum myEnum) { switch (myEnum) { case
I have following method in wcf webenabled service Public Person AddPerson(Person p); As of
Consider the following method, public void Add(Enum key, object value); Since Enum is a
I have the following interface public interface DeviceKey { String getKey(); } I also
I have an enum class like the following: public enum Letter { OMEGA_LETTER(Omega), GAMMA_LETTER(Gamma),
Consider the following enumeration: [System.Flags] public enum EnumType: int { None = 0, Black
I have the following domain entity objects: public class Report { public virtual int
I have the three following enums: public enum SensorTypeA{A1,A2,...,A12}; public enum SensorTypeB{B1,B2,...,B12}; public enum

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.