CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Threaded View

  1. #1
    Join Date
    Aug 2006
    Posts
    22

    Smile Reflection for generics .NET 2.0

    Hello,
    I have a generic collection class.

    Code:
    public class CustomTypeCollection<T>: ICustomTypeCollection<T>, IEnumerable<T> where T:class,ICustomType, new()
        {
            
            List<T> collection=new List<T>();
       
    
            public CustomTypeCollection()
            { 
            
            }
    
            public void Add(T item)
            {
                collection.Add(item);
                
            }
    
            public T Item(int index)
            {
                return collection[index];
            }
     
            IEnumerator IEnumerable.GetEnumerator()
            {
                { return collection.GetEnumerator(); }
            }
    
           IEnumerator<T> IEnumerable<T>.GetEnumerator()
           {
               { return collection.GetEnumerator(); }
           }
    T type is not known at compile. I would like to be able to dinamically set it up at runtime. Is there a way to accomplish it nicely?

    Thank you,
    Serge
    Last edited by cjard; April 23rd, 2008 at 05:22 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured