求C#里sort()函数封装的源代码

来源:百度知道 编辑:UC知道 时间:2024/05/21 12:06:42
C#里的.谢谢啦
因为现在在学接口
那几个系统接口的用法搞的不是很懂
所以希望能看看sort()的源码

同意楼上说法,用reflector就可以,这是其中的一部分代码,建议去看reflector。

1.Sort() : Void
public void Sort()
{
this.Sort(0, this.Count, null);
}
2.Sort(IComparer<T>):Void
public void Sort(IComparer<T> comparer)
{
this.Sort(0, this.Count, comparer);
}
1和2的this.Sort:
public void Sort(int index, int count, IComparer<T> comparer)
{
if ((index < 0) || (count < 0))
{
ThrowHelper.ThrowArgumentOutOfRangeException((index < 0) ? ExceptionArgument.index : ExceptionArgument.count, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
}
if ((this._size - index) < count)
{
ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen);
}
Array.Sort<T>(this._items, index, count, comparer);
this._version++;
}

3.Sort(Comparison<T>):Void
public void Sort(Comparison<T> comparison)
{
if (comp