InvalidCastException

image_pdfimage_print
   
  

using System;
   
class MainClass
{
    public static void Main()
    {
        try
        {
            MainClass       MyObject = new MainClass();
            IFormattable    Formattable;
   
            Formattable = (IFormattable)MyObject;
        }
        catch(InvalidCastException)
        {
            Console.WriteLine("MyObject does not implement the IFormattable interface.");
   
        }
    }
}
           
         
    
     


This entry was posted in Data Types. Bookmark the permalink.