Good day!
In Java, using enums, you can add your own methods to them:
enum Type { INT(true) { public Object parse(String string) { return Integer.valueOf(string); } }, INTEGER(false) { public Object parse(String string) { return Integer.valueOf(string); } }, STRING(false) { public Object parse(String string) { return string; } }; boolean primitive; Type(boolean primitive) { this.primitive = primitive; } public boolean isPrimitive() { return primitive; } public abstract Object parse(String string); } Trying to do this in C #, I get a compile error. Am I doing something wrong or is this feature not implemented in Sharpe?
Everyone knows that C # and Java as programming languages ββare very similar, which is why I draw an analogy for a more detailed description of the issue. I do not ask you and do not want to compare them myself, but rather to find out which is better, so that. do not do this.
Thank you in advance!