Collections Data Structure C#

namespace Ngs.Collections
{
    // Copyright (c) Microsoft Corporation.  All rights reserved.
    // This source code is made available under the terms of the Microsoft Public License (MS-PL)
    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.Linq;
    using System.Reflection;
    using System.Text;
    public static class ReadOnlyExtensions
    {
        internal static ReadOnlyCollection ToReadOnly(this IEnumerable collection)
        {
            ReadOnlyCollection roc = collection as ReadOnlyCollection;
            if (roc == null)
            {
                if (collection == null)
                {
                    roc = EmptyReadOnlyCollection.Empty;
                }
                else
                {
                    roc = new List(collection).AsReadOnly();
                }
            }
            return roc;
        }
        class EmptyReadOnlyCollection
        {
            internal static readonly ReadOnlyCollection Empty = new List().AsReadOnly();
        }
    }
}