Created
August 28, 2018 23:58
-
-
Save vexx32/e61df1919f8eae9ef3156372ab18a50b 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
// Generic this --> multiple type handling | |
internal static bool TryConvertSByte(double value, out sbyte outValue) | |
{ | |
if (value < sbyte.MinValue || value > sbyte.MaxValue) | |
{ | |
outValue = 0; | |
return false; | |
} | |
outValue = (sbyte)Math.Round(value); | |
return true; | |
} | |
internal static bool TryConvert<T>(double value, out T outValue) where T : struct | |
{ | |
switch (T) | |
{ | |
case Type T when T == sbyte: | |
// stuff | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment