Q:

Beginner: Extending a class in C#, am I doing it wrong?

Again disclaimer disclaimer still learning C# and OOP generally so I hope you'll be patient with me :)
I am currently working with a CMS that has a class called FileVersion which basically contains a list of properties pertaining to a file such as filename, filetype, size in bytes, id, date uploaded, is-latest-version, etc.
A list of FileVersions is contained within a File which has it's own unique ID. When you want to download a particular file from the CMS, the URL is built using something like the following:
string URL = "/files/"+file.id.toString()+"/"+file.fileVersion.Last().filename;

Now for a particular control I'm working on (dealing specifically with files that are documents), it makes sense to be able to store the URL along with all the other FileVersion information for later use. So what I've decided to do is create my own class called DocumentVersion which extends FileVersion. This is what it looks like:
public partial class DocumentVersion : FileVersion
{
    public DocumentVersion() : base() { }
    public string link;
}

Now I should note, that it appears that I don't need to implement an interface here - but don't take that as gospel, that's why I'm here. 
However when I try to cast my FileVersion as a DocumentVersion like so:
DocumentVersion dv = ((DocumentVersion)fileversion);

I get the following exception:

Unable to cast object of type
  'Foo.CMS.FileVersion' to type
  'CoA.DocumentVersion'.

My inkling is that it's because I'm trying to extend a class in a different namespace from where the original resides, but like I said, OOP is relatively new to me so I could be wrong.
Thanks in advance for your help. This community has been so valuable! I just hope once I'm more skilled up I can give some back :).

A:

Are you trying to downcast ? i.e. take an existing FileVersion and declare it to be a DocumentVersion ?
If so, you can't do that, since what you have is nothing more than a FileVersion. 
Instead you need to create a new DocumentVersion object. Your DocumentVersion constructor will take the arguments required for a FileVersion and then call the FileVersion constructor via base().
Note that if you have an existing FileVersion object, you may want an object to wrap this, rather than have an object deriving from it. e.g. your DocumentVersion wouldn't derive from FileVersion, but contain a private reference to a FileVersion, plus additional data as required. That may be more appropriate in this scenario.
e.g. (in OO terms this is composition)
public class DocumentVersion {
   private FileVersion fv;
   private String url;
   public DocumentVersion(FileVersion fv, String url) {
      this.fv = fv;
      this.url = url;
   }
}

See here for more info on composition.

A:

You cannot cast your FileVersion to DocumentVersion because your fileversion variable contains a FileVersion, not a DocumentVersion. Inheritance means the following:

Every DocumentVersion is a FileVersion, but
Not every FileVersion is a DocumentVersion!

If the object was created as a FileVersion, it's just a FileVersion. Period. If it was created as a DocumentVersion, you can use it everywhere where you would use a FileVersion (see rule #1 above), and you can use the DocumentVersion features of it.
So, when creating the FileVersion object, you need to create a DocumentVersion instead (if you have control over that part of the code), then the cast will work. Those DocumentVersions could be stored in the same list as the FileVersions, since every DocumentVersion is also a FileVersion.

EDIT: Since the above two rules are so vital to understanding the OO principle, let me illustrate them with an example: DocumentVersion = dog and FileVersion = animal. Then the above rules would be: (1) Every dog is an animal, but (2) not every animal is a dog. So, you can create a list of animals, store all kinds of animals in there (dogs, cats, things that are just "animal", ...), but you cannot cast a variable of type animal to a dog, unless what is in there has been created as a dog (or as a poodle (class poodle : dog), which is a dog by rule (1)).
In OO terms: If you store a dog in a variable of type animal, then the static type of the object is "animal", and the dynamic type is "dog". You can only cast an element to some type T if its dynamic type is T or a subtype thereof.

