"Lasse Edsvik" <la***@nospam.com> wrote in message
news:OG**************@TK2MSFTNGP12.phx.gbl...
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
--
http://www.csharp-station.com