Created
December 25, 2016 19:52
-
-
Save atsvetkov/b5a903fad4daf8874f407c5f9cdb2456 to your computer and use it in GitHub Desktop.
This file contains 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
public static bool TryParse(object number, out int result) | |
{ | |
switch (number) | |
{ | |
case int i: | |
result = i; | |
return true; | |
case string s: | |
return ParseString(s, out result); | |
default: | |
throw new NotSupportedException($"{nameof(IntegerParser)} only accepts strings ans integers, type '{number.GetType()}' is not supported"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment