Last active
October 12, 2022 17:03
-
-
Save sujoyu/9a113c5f61c31874cc529fee0e9ab095 to your computer and use it in GitHub Desktop.
C# enum like Java sample.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
public class EnumLikeJava { | |
public static readonly EnumLikeJava enum1 = new EnumLikeJava("enum1", (s) => s + "foo"); | |
public static readonly EnumLikeJava enum2 = new EnumLikeJava("enum2", (s) => s + "bar"); | |
public static readonly EnumLikeJava enum3 = new EnumLikeJava("enum3", (s) => s + "baz"); | |
public readonly string Field; | |
public readonly Func<string, string> _method; | |
private EnumLikeJava(string field, Func<string, string> method) { | |
Field = field; | |
_method = method; | |
} | |
public string Method(string param) { | |
return _method (param); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment