How to extend from two classes in C#

You can’t extend from two classes because the language designers decided not to. This is not a writeup why it’s done in Java and not in C#. There are plenty of good articles and answers covering it like https://stackoverflow.com/a/995271/1329173

Use two interface and not two classes

The way you would do it in C# is using interfaces and not classes. First create the two or more interfaces needed.

interface IFoo 
{
    void A(); 
}

interface IBar
{
    void B();
}

Now implement each one in a class.

class Foo : IFoo
{
    public void A()
    {
         // code
    }
}

class Bar : IBar 
{
    public void B()
    {
         // code 
    }
}

Lastly you can include both interface and inject the other classes.

public class Baz : IFoo, IBar
{
    IFoo foo = new Foo(); // or inject 
    IBar bar = new Bar(); // or inject

    public void A()
    {
        foo.A();
    }

    public void B()
    {
        bar.B();
    }
}