ReadOnlyCollectionBase.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / BCL / System / Collections / ReadOnlyCollectionBase.cs / 1305376 / ReadOnlyCollectionBase.cs

                            // ==++== 
//
//   Copyright (c) Microsoft Corporation.  All rights reserved.
//
// ==--== 
//------------------------------------------------------------------------------
//----------------------------------------------------------------------------- 
// [....] 
//
 
namespace System.Collections {

    using System;
 
    // Useful base class for typed readonly collections where items derive from object
    [Serializable] 
    [System.Runtime.InteropServices.ComVisible(true)] 
    public abstract class ReadOnlyCollectionBase : ICollection {
        ArrayList list; 

        protected ArrayList InnerList {
            get {
                if (list == null) 
                    list = new ArrayList();
                 return list; 
            } 
        }
 
        public virtual int Count {
            get { return InnerList.Count; }
        }
 
        bool ICollection.IsSynchronized {
            get { return InnerList.IsSynchronized; } 
        } 

        object ICollection.SyncRoot { 
            get { return InnerList.SyncRoot; }
        }

        void ICollection.CopyTo(Array array, int index) { 
            InnerList.CopyTo(array, index);
        } 
 
        public virtual IEnumerator GetEnumerator() {
            return InnerList.GetEnumerator(); 
        }
    }

} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.


                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK