Class Design C# Casting <p>Let's say I have a program to write text into a file (not really but that's easier to explain). I want a seperate class for each filetype like PdfType and WordType that inherit from a FileTypeMaster.</p> <pre><code>FileTypeMaster (base) -PdfType : FileTypeMaster -WordType : FileTypeMaster (same methods as pdftype but works different) </code></pre> <p>Now to the real problem... I want the user to decide on programstart what type to use. If he wants Pdf OR Word the methodcall should look the same (because word is new and the program was just for pdf before).</p> <p>How it should work for example with pdf:</p> <pre><code>static FileTypeMaster MyFavoriteType; //declare a general var MyFavoriteType = new PdfType(); //cast general var to the wanted type MyFavoriteType.CompileThis(); </code></pre> <p>How it should work with word: the same but MyFavoriteType = new WordType();`</p>