User-Defined Conversions : Casting Conversions : Data Types C# Source Code


Custom Search

C# Source Code » Data Types » Casting Conversions »

 

User-Defined Conversions








    



// This demo has compiling error
class S
{
}
class TBase
{
}
class T: TBase
{
    public static implicit operator T(S s) 
    {
        return(new T());
    }
}

public class ConversionLookup1
{
    public static void Main()
    {
        S myS = new S();
        TBase tb = (TBase) myS;
    }
}

           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Data Types
» Casting Conversions