Run Code
|
Code Wall
|
Users
|
Misc
|
Feedback
|
About
|
Login
|
Theme
enum extension
using System; namespace Rextester { public enum State : int { StateA = 1, StateB } public enum DifferentState : int { StateA = 1, StateB } public static class Extensions { public static bool CompareInt(this Enum lhs, int rhs) { return Convert.ToInt32(lhs) == rhs; } } public class Program { public static void Main(string[] args) { State foo = State.StateA; Console.WriteLine(foo.CompareInt(1)); Console.WriteLine(foo.CompareInt(2)); DifferentState bar = DifferentState.StateB; Console.WriteLine(bar.CompareInt(1)); Console.WriteLine(bar.CompareInt(2)); } } }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Constructor inheriterance
linked list reversal recursive
c# integers
Immutable
SHA Tester 2.0
Gzip string and back
nested try catch
z
Joro Football Player
My quad calc
Please log in to post a comment.