Conversion Lookup

image_pdfimage_print
   
  

/*
A Programmer's Introduction to C# (Second Edition)
by Eric Gunnerson

Publisher: Apress  L.P.
ISBN: 1-893115-62-3
*/

// 24 - User-Defined ConversionsHow It WorksConversion Lookup
// copyright 2000 Eric Gunnerson

public class ConversionLookup
{
    public static void Main()
    {
        S myS = new S();
        TBase tb = (TBase) myS;
    }
}
public class S
{
    public static implicit operator T(S s) 
    { 
        // conversion here
        return(new T());
    }
}

public class TBase
{
}

public class T: TBase
{
    
}


           
         
    
     


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