Typecasting interface to a class object in c#
<p>I wanted to know if the below typecasting I am doing is correct or not ?</p>

<pre><code> Interface IA 
{
      string AName {get;set;}
      string A_Address {get;set;} 
      UpdateA_Address();
}
 Interface IB 
{
      string BName {get;set;}
      string B_Address {get;set;} 
      UpdateB_Address();
}
public class A : IA
{
    ///implemented both prop
    public void MethodNotInterfaceA()
    {
       //Some stuff
    }
}
public class B : IB
{
    ///implemented both prop
    public void MethodNotInterfaceB()
    {
       //Some stuff
    }   
}
public class X
{
   IA aObj {get;set;}
   IB bObj {get;set;}

   public x()
   {
    aObj = new A();
    bObj = new B();          
   }

   public void SomeMethod1()
   {
      //some stuff here
      aObj.UpdateB_Address();
      aobj.MethodNotInterfaceB(); =============&gt; is telling method not impemeted not part of interface
      (aObj as A).MethodNotInterfaceB(); =============&gt; this casting an interface to an class type is valid
   }

   public void SomeMethod2()
   {
      //some stuff here
      bObj.UpdateB_Address(); 
      bObj.MethodNotInterfaceB(); =============&gt; is telling method not impemeted not part of interface
      (bObj as B).MethodNotInterfaceB(); =============&gt; this casting an interface to an class type is valid
   }
}
</code></pre>

<p>These interfaces are common to other classes hence the  MethodNotInterfaceB() is not part of it and I want to access this in class X so am converting into a class object from interface type.</p>

<p>Can you please let me know if this is valid and error handling do i need take care while typecasting.</p>

<p>FYI --- it is building without any errors and working <code>enter code here</code>fine also</p>

<p>Thanks,
Vinod </p>