#620 – Inherit from a Class In A Different Assembly

You can create a new class that inherits from a class that exists in another assembly (e.g. in a class library), as long as the parent class is public (and not sealed).

Let’s assume that someone gives you a copy of DogLibrary.dll, which includes two classes–a Dog class, which is defined as public and a DogMath class, which is defined as internal.

In another program, you can inherit from the Dog class, as long as you add a reference to the DogLibrary assembly.

You inherit from the Dog class just like you inherit from a class within your own program.

    public class Program
        public class CrazyDog : Dog
            public override void Bark()

        static void Main()
            CrazyDog myDog = new CrazyDog();

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: