Invalid Cast Exceptions with Implicit Operators : stackalloc : Language Basics C# Source Code


Custom Search

C# Source Code » Language Basics » stackalloc »

 

Invalid Cast Exceptions with Implicit Operators








    
 


public class TestClass
{
    private MainClass MyMainClassObject;
   
    public TestClass()
    {
        MyMainClassObject = new MainClass();
    }
   
    public static implicit operator MainClass(TestClass Source)
    {
        return Source.MyMainClassObject;
    }
}
   
public class MainClass
{
    public static void Main()
    {
        object MyObject;
        MainClass MyMainClassObject;
   
        MyObject = new TestClass();
        MyMainClassObject = (MainClass)MyObject;
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Language Basics
» stackalloc