Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. why my enum return value is in integer in C#

why my enum return value is in integer in C#

Scheduled Pinned Locked Moved C#
csharphelpquestion
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nicolus
    wrote on last edited by
    #1

    i have a enum type with the following defination enum enumCatalogExportStandard { CatccExportAsISO, CatccExportAsFGDC, CatccExportAsNative }; enumCatalogExportStandard ImportStandard ; ImportStandard = enumCatalogImportStandard.CatccImportAsISO ; ImportStandard is showing value as 1 instead of CatccExportAsISO how can i get the "CatccExportAsISO " instead of 1. Please help me.

    L 1 Reply Last reply
    0
    • N nicolus

      i have a enum type with the following defination enum enumCatalogExportStandard { CatccExportAsISO, CatccExportAsFGDC, CatccExportAsNative }; enumCatalogExportStandard ImportStandard ; ImportStandard = enumCatalogImportStandard.CatccImportAsISO ; ImportStandard is showing value as 1 instead of CatccExportAsISO how can i get the "CatccExportAsISO " instead of 1. Please help me.

      L Offline
      L Offline
      Lutoslaw
      wrote on last edited by
      #2

      Please post which method do you use to visualize enumeration variable's value. To obtain a text representation, try ImportStandard.ToString() method.

      Greetings - Gajatko Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.

      N 1 Reply Last reply
      0
      • L Lutoslaw

        Please post which method do you use to visualize enumeration variable's value. To obtain a text representation, try ImportStandard.ToString() method.

        Greetings - Gajatko Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.

        N Offline
        N Offline
        nicolus
        wrote on last edited by
        #3

        i tried to display the value "ImportStandard.ToString() " using messagebox it returned 1 only. can u please tell me some other alternative.

        L 1 Reply Last reply
        0
        • N nicolus

          i tried to display the value "ImportStandard.ToString() " using messagebox it returned 1 only. can u please tell me some other alternative.

          L Offline
          L Offline
          Lutoslaw
          wrote on last edited by
          #4

          This is an alternative:

          MessageBox.Show(Enum.GetName(typeof(enumCatalogExportStandard ), ImportStandard));

          But... it is impossible. The code:

          enum alph { A, B, C }
          alph ph = alph.A;
          MessageBox.Show(ph.ToString());

          gives me "A"... Please post the full code.

          Greetings - Gajatko Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.

          N 1 Reply Last reply
          0
          • L Lutoslaw

            This is an alternative:

            MessageBox.Show(Enum.GetName(typeof(enumCatalogExportStandard ), ImportStandard));

            But... it is impossible. The code:

            enum alph { A, B, C }
            alph ph = alph.A;
            MessageBox.Show(ph.ToString());

            gives me "A"... Please post the full code.

            Greetings - Gajatko Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.

            N Offline
            N Offline
            nicolus
            wrote on last edited by
            #5

            hi Gajatko, i don't know why any alternative is not working in my m/c. when i tried MessageBox.Show(Enum.GetName(typeof(enumCatalogExportStandard ), ImportStandard)); gave me a null string as output. i am sending the code snippets where ever i am using the enum related stuff in my code pls view. public enum enumCatalogImportStandard { CatccImportAsISO, CatccImportAsFGDC, CatccImportAsNative }; enumCatalogImportStandard ImportStandard; private void cmbTargetstd_SelectedIndexChanged(object sender, EventArgs e) { if (cmbTargetstd.SelectedItem.ToString() == "ISO") ImportStandard = enumCatalogImportStandard.CatccImportAsISO ; else if (cmbTargetstd.SelectedItem.ToString() == "FGDC") ImportStandard = enumCatalogImportStandard.CatccImportAsFGDC ; else if (cmbTargetstd.SelectedItem.ToString() == "Native") ImportStandard = enumCatalogImportStandard.CatccImportAsNative; } private void btnApply_Click(object sender, EventArgs e) { CImportCatalogRecordService.ImportCatalogRecordService objImpRecService = new CImportCatalogRecordService.ImportCatalogRecordService(); //below statement returning number instead of string objImpRecService.ImportStandard = ImportStandard; objImpRecService.InputFileName = txtImportFolder.Text + "\\" + Rec; objImpRecService.CatalogConnection = con; objImpRecService.Execute(out MetadataID); } this is all my code Pls view.

            L 1 Reply Last reply
            0
            • N nicolus

              hi Gajatko, i don't know why any alternative is not working in my m/c. when i tried MessageBox.Show(Enum.GetName(typeof(enumCatalogExportStandard ), ImportStandard)); gave me a null string as output. i am sending the code snippets where ever i am using the enum related stuff in my code pls view. public enum enumCatalogImportStandard { CatccImportAsISO, CatccImportAsFGDC, CatccImportAsNative }; enumCatalogImportStandard ImportStandard; private void cmbTargetstd_SelectedIndexChanged(object sender, EventArgs e) { if (cmbTargetstd.SelectedItem.ToString() == "ISO") ImportStandard = enumCatalogImportStandard.CatccImportAsISO ; else if (cmbTargetstd.SelectedItem.ToString() == "FGDC") ImportStandard = enumCatalogImportStandard.CatccImportAsFGDC ; else if (cmbTargetstd.SelectedItem.ToString() == "Native") ImportStandard = enumCatalogImportStandard.CatccImportAsNative; } private void btnApply_Click(object sender, EventArgs e) { CImportCatalogRecordService.ImportCatalogRecordService objImpRecService = new CImportCatalogRecordService.ImportCatalogRecordService(); //below statement returning number instead of string objImpRecService.ImportStandard = ImportStandard; objImpRecService.InputFileName = txtImportFolder.Text + "\\" + Rec; objImpRecService.CatalogConnection = con; objImpRecService.Execute(out MetadataID); } this is all my code Pls view.

              L Offline
              L Offline
              Lutoslaw
              wrote on last edited by
              #6

              nicolus wrote:

              //below statement returning number instead of string

              objImpRecService.ImportStandard = ImportStandard;

              Of course it returns a number. Change it to:

              objImpRecService.ImportStandard = ImportStandard**.ToString()**;

              Greetings - Gajatko Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups