I have problems converting Java to C# enums.
Is there anything special that needs to be done in C# enum for the conversion to work?
The following is a sample Java enum that is not converting:
public enum GroupBySummaryType {
SUM("Total", "SUM"),
MAX("Maximum","MAX"),
MIN("Minimum", "MIN"),
AVG("Average","AVG"), // Mean
STDDEV("Standard deviation","STDDEV"),
VAR("Variance","VAR"),
COUNT("Count","COUNT");
GroupBySummaryType(final String uiDisplay, final String macro) {
m_uiDisplay = uiDisplay;
m_macro = macro;
}
@Override
public String getDescription() {
return m_uiDisplay;
}
@Override
public String getMacroString() {
return m_macro;
}
private String m_uiDisplay;
private String m_macro;
}
It is not possible to get this type of ENUM completely over to C#.
The problem is actually, that C# does not allow for ENUMs to have multiple fields, as is possible in Java, so your ENUM in C# must (and can only) look something like the following:
public enum GroupBySummaryType {
SUM,
MAX,
MIN,
AVG, // Mean
STDDEV,
VAR,
COUNT;
}
That is very unfortunate, but as I said, C#-ENUMs are not as powerful as the Java ones.
Cheers, Arndt
Do you think there is a working around like Java enum to C# constants?
PHP does not support enums, but the PHP translation will push Java enum to a class of constants.
GroupBySummaryType in PHP hessian conversion:
class GroupBySummaryType {
const SUM = 1;
const MAX = 2;
const MIN = 3;
const AVG = 4;
const STDDEV = 5;
const VAR = 6;
const COUNT = 7;
}
I'm not looking for a full conversion, but something that will get the values into C#.
Thanks,
Malcolm
Yes, you can make an ENUM in C# that have ints associated.
Just remember to use the same namespace for the C# Enum, as you used in Java, then the conversion should work (works in our Code ;) )
Cheers, Arndt