我是C#的初学者,现在正在学习泛型,是拿.ner framework的类库中的List<T>类的源代码做例子,下面是源代码
有几行看不懂,望高手指教, [DebuggerTypeProxy(typeof(Mscorlib_CollectionDebugView<>))]
[DebuggerDisplay("Count = {Count}")]
[Serializable]
public class List<T> : IList<T>, System.Collections.IList
{
private const int _defaultCapacity = 4;//默认容量
private T[] _items;
[ContractPublicPropertyName("Count")]
private int _size;
private int _version;
[NonSerialized]
private Object _syncRoot;
static readonly T[] _emptyArray = new T[0]; // Constructs a List. The list is initially empty and has a capacity
// of zero. Upon adding the first element to the list the capacity is
// increased to 16, and then increased in multiples of two as required.#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
public List() {
_items = _emptyArray;
} // Constructs a List with a given initial capacity. The list is
// initially empty, but will have room for the given number of elements
// before any reallocations are required.
#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
public List(int capacity) {
if (capacity < 0) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.capacity, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
Contract.EndContractBlock();
_items = new T[capacity];
}
====================================
以下几行代码看不懂,望高手指点这几行是分别什么意思
[DebuggerTypeProxy(typeof(Mscorlib_CollectionDebugView<>))]
[DebuggerDisplay("Count = {Count}")]
[Serializable] #if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
有几行看不懂,望高手指教, [DebuggerTypeProxy(typeof(Mscorlib_CollectionDebugView<>))]
[DebuggerDisplay("Count = {Count}")]
[Serializable]
public class List<T> : IList<T>, System.Collections.IList
{
private const int _defaultCapacity = 4;//默认容量
private T[] _items;
[ContractPublicPropertyName("Count")]
private int _size;
private int _version;
[NonSerialized]
private Object _syncRoot;
static readonly T[] _emptyArray = new T[0]; // Constructs a List. The list is initially empty and has a capacity
// of zero. Upon adding the first element to the list the capacity is
// increased to 16, and then increased in multiples of two as required.#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
public List() {
_items = _emptyArray;
} // Constructs a List with a given initial capacity. The list is
// initially empty, but will have room for the given number of elements
// before any reallocations are required.
#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
public List(int capacity) {
if (capacity < 0) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.capacity, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
Contract.EndContractBlock();
_items = new T[capacity];
}
====================================
以下几行代码看不懂,望高手指点这几行是分别什么意思
[DebuggerTypeProxy(typeof(Mscorlib_CollectionDebugView<>))]
[DebuggerDisplay("Count = {Count}")]
[Serializable] #if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
解决方案 »
- 关于右键菜单的问题
- 《C#入门经典》中发现的一个错误
- 急,急, c#中字符串替换的问题
- C#如何锁定excel的cell?
- 我想问的是中间那个业务层机器 从数据库提取数据到DataSet,然后转交给用户层后,这时候DataSet数据还在业务层机器上存在不了??
- 如何引用系统自动生成的连接串
- 关于表单提交的问题,涉及http请求.请高手不吝赐教
- 请问怎样用C#把两个表 合为一个表显示?
- 请高手指点,在面向对象编程的思想的C#(asp.net)如何进行统计汇总?谢谢!
- 在windows 98 下的应用程序为什么不能访问web services?
- 请教“判断几个文本框,内容不为空的交集输出”问题
- wpf数据绑定问题
[DebuggerTypeProxy(typeof(Mscorlib_CollectionDebugView<>))]
[DebuggerDisplay("Count = {Count}")]//上面两个是给Visual studio看的 帮助你调试
[Serializable] //可序列化
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]//没怎么看懂,好像是说如果对性能要求很高,可以通过NGen这个本地代码生成器把方法内联