Return string + enum?

  • Thread starter Thread starter Lasse Edsvik
  • Start date Start date
L

Lasse Edsvik

Hello

I was wondering if it's possible to return both a string and an enum value?
both "I have a caddilac" and CADDILAC? as an example..

if so, could you guys show me?

TIA
/Lasse
 
Lasse Edsvik said:
Hello

I was wondering if it's possible to return both a string and an enum value?
both "I have a caddilac" and CADDILAC? as an example..


Hi /Lasse,

Here is one way (pseudo code - I didn't compile this):

public string MyMethod(out MyEnumType myEnum)
{
// do method stuff
myEnum = MyEnumType.CADDILAC;
return "I have a caddilac";
}

Call it like this:

MyEnumType anEnum;

string myString = MyMethod(out anEnum);

Console.WriteLine("Enum: {0}, String: {1}", anEnum, myString);

Other possibilities include creating a struct with the enum and string type
and returning the struct, returning an enum from the method and making the
string an out parameter, or making both the enum and the string out
parameters.

Joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Enum TypeConverter 3
Enum Extentions 7
about enum 3
Merge Info From Two Enums 1
finding an Enum using the string name of it 4
Enums & Constructors? 4
I have small probalem 4
Arrays of List collections 4

Back
Top