title: Explicit operator cast on runtime
body: <p>I'm working on a asp.net project in Kentico.</p>
  
  <p>Currently I created a Model, let's call it PartnerModel. It contains a private variable of the type TreeNode, which basically holds the same informations in a different form.</p>
  
  <p>I want to be able to cast an instance of a PartnerModel explicit to a TreeNode.
  This should happen at runtime (in a WebForms User Control).</p>
  
  <p><strong>Edit:</strong> I'm not searching for "better" ways to achieve something like I'm asking for. This is more a general purpose with no explicit use case. The code below is just what I tried to do. I just want to know, if it is possible to cast my model explicit during runtime and if so, how I can do it.</p>
  
  <p>Is this possible? I just get an InvalidCast Exception.</p>
  
  <p><em>PartnerModel.cs</em></p>
  
  <pre><code>public class PartnerModel
  {
          #region Public Properties
  
          public TreeNode Node { get { return node; } }
          ...
          public static explicit operator TreeNode(PartnerModel model)
          {
              return model.node;
          }
  }
  </code></pre>
  
  <p><em>PartnerOverview.ascx</em></p>
  
  <pre><code>...
  &lt;cms:BasicRepeater runat="server" ID="RepeaterPartner"&gt;
                  &lt;ItemTemplate&gt;
                      &lt;a href="&lt;%# ((CMS.DocumentEngine.TreeNode)Container.DataItem).RelativeURL %&gt;"&gt;
  ...
  </code></pre>