Skip to content

Instantly share code, notes, and snippets.

@todorok1
Last active November 2, 2020 05:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save todorok1/92c6550a645edd9e8fba18e51201b191 to your computer and use it in GitHub Desktop.
Save todorok1/92c6550a645edd9e8fba18e51201b191 to your computer and use it in GitHub Desktop.
ジェネリックで制約を設定する
/// <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