Q: Use a generic method for an unknown class? Here what I want to do using C#:
unknownClass handle;

if(blabla)
    handle = new A();
else
    handle = new B();

handle.CommonMethod();

Obviously, classes A and B both have the method CommonMethod.
How can I do that?

A: Have both A and B implement an interface that has a method, CommonMethod.  Use that interface in place of unknownClass.

A: You can use interface for this job:
interface ICommon
    {
        void CommonMethod();
    }

    public class A : ICommon  
    { 
        //implement CommonMethod 
    }

    public class B : ICommon 
    { 
        //implement CommonMethod 
    }

then:
ICommon handle;

if(blabla)
   handle = new A();
else
   handle = new B();

handle.CommonMethod();


A: As already stated, you should use interfaces.
Example:
public interface IBarking{
   public void Barks();
}

public class Dog : IBarking{
  //some specific dog properties
  public void Barks(){
    string sound = "Bark";
  }
}


public class Wolf : IBarking{
  //some specific wolf properties
  public void Barks(){
    string sound = "Woof";
  }
}

//and your implementation here:

IBarking barkingAnimal;
if (isDog){
  barkingAnimal = new Dog();
}
else {
  barkingAnimal = new Wolf();
}
barkingAnimal.Barks();


A: An interface or common base-class should always be the preferred option here. I would actually introduce an interface and wrapper classes for each concrete type if I needed. When no other option is possible, though:
dynamic obj = ...
obj.CommonMethod(); // this is a hack

But: do everything else first. Like I say: wrapper types would be preferable if you can't edit the objects themselves:
IFoo obj;
...
obj = new BarWrapper(new Bar());
...
obj.CommonMethod();

