Results 1 to 3 of 3

Thread: Make abstract class only visible to my classes

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276

    Question Make abstract class only visible to my classes

    I have an abstract class and I only want it visible to my classes only. If somebody references the library, I don't want them to be able to inherit from my abstract class.
    Code:
    // Class1.cs
    
    abstract class Class1
    {
    }
    Code:
    // Class2.cs
    
    public class Class2 : Class1
    {
    }
    The compile error tells me Class1 is less accessible than Class2.

    Making Class1 public works but it makes it visible and (inheritable) by any other class but I only want it to be inherited by the classes I specify. Is this possible or necessary?

  2. #2
    Addicted Member
    Join Date
    Jan 2005
    Location
    Montréal
    Posts
    160

    Re: Make abstract class only visible to my classes

    Use internal instead of public.

    It makes your class only accessible for the project in which it is located.
    There are no stupid questions, but a whole bunch of dumb sayings !

    Save time on database code, try DataLG !

  3. #3
    Addicted Member
    Join Date
    Jan 2005
    Location
    Montréal
    Posts
    160

    Re: Make abstract class only visible to my classes

    excuse my previous post, it doesn't address your problem effectively.
    There are no stupid questions, but a whole bunch of dumb sayings !

    Save time on database code, try DataLG !

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