小编Die*_*ken的帖子

为什么'typeof(string).FullName'给'System.String'而不是'string'?

为什么typeof(string).FullName给予System.String而不给予string?同样是与所有其他"简单"类型,如int,float,double,...

我明白这typeof是返回System.Type给定类型的对象,但为什么string不是一个System.Type对象呢?

是因为它string是c#语言的System.Type一部分,并且是系统库的一部分吗?

c# types typeof

5
推荐指数
1
解决办法
1092
查看次数

此搜索方法中IComparable和IComparable <T>之间的差异

我知道,有一个很大的区别IComparable,并IComparable<T>在一般情况下,看到,但在这个搜索方法就没有任何区别,还是会?

public static int Search<T>(List<T> a, T target) where T : IComparable
{
    for (int i = 0; i < a.Count; i++)
    {
        if (target.CompareTo(a[i]) == 0)
            return i;
    }
    return -1;
}
Run Code Online (Sandbox Code Playgroud)

相比:

public static int Search<T>(List<T> a, T target) where T : IComparable<T>
{
    ...
}
Run Code Online (Sandbox Code Playgroud)

两者都会起作用并给出相同的结果吗?

c# icomparable icomparablet

4
推荐指数
1
解决办法
523
查看次数

标签 统计

c# ×2

icomparable ×1

icomparablet ×1

typeof ×1

types ×1