-
-
Save todorok1/92c6550a645edd9e8fba18e51201b191 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
/// <Summary> | |
/// 引数の値を比較するメソッドです。 | |
/// </Summary> | |
T GetLargerValue<T>(T a, T b) | |
where T: IComparable | |
{ | |
if (a.CompareTo(b) > 0) | |
{ | |
return a; | |
} | |
else | |
{ | |
return b; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment