Results 1 to 2 of 2

Thread: Returning readonly version of object

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2000
    Location
    Europe, Lithuania
    Posts
    309

    Question Returning readonly version of object

    Hello,

    Need urgent help. Hope for good solution.

    I have two classes inherited from System.Collections.CollectionBase.


    Code:
    public class1: System.Collections.CollectionBase
    { //.. }
    
    public class2: System.Collections.CollectionBase
    { 
    
        private class1 obj = new class1();
    
        public class1 MyReadOnlySubClass 
        {
               get { return class1; }
        } 
    
         //.. 
    }
    So I return class1 as property in class2. How to hide returned class'es methods such Add, Clear, Insert, RemoveAt? I only need ability to enumerate this class with foreach and get all child objects.


    Regards in advance,
    Andrius

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2000
    Location
    Europe, Lithuania
    Posts
    309

    Re: Returning readonly version of object

    Also I think there may be same problem with class1's inner object collections.

    If I could return readonly version of class1 in class2, then calling to inner object of this returned class, they would be read-write, not read-only.

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