why my enum return value is in integer in C#
-
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.
-
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.
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.
-
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.
-
i tried to display the value "ImportStandard.ToString() " using messagebox it returned 1 only. can u please tell me some other alternative.
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.
-
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.
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.
-
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.
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.