[英]static generic method in C#
I have this java method signature: 我有这个java方法签名:
public static <T extends Comparable<T>> Queue<T> naturalMergeSort(Queue<T> input)
what would the C# equivalent be? C#等效项是什么?
The C# equivalent would be: C#等效项为:
public static Queue<T> naturalMergeSort<T>(Queue<T> input) where T : IComparable<T>
Note that in C# the interface is IComparable<T>
instead of Comparable<T>
, and the generic argument goes at the end of the method name as well. 请注意,在C#中,接口是
IComparable<T>
而不是Comparable<T>
,并且通用参数也位于方法名称的末尾。
在C#中将如下所示:
public static Queue<T> NaturalMergeSort<T>(Queue<T> input) where T : IComparable<T>{}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.