using System;
class MyDataType
{
public static explicit operator int(MyDataType li) // Convert type
{
Console.WriteLine("explicit operator int");
return 0;
}
public static explicit operator MyDataType(int x) // Convert type
{
Console.WriteLine("public static explicit operator MyDataType");
return new MyDataType();
}
}
class MainClass
{
static void Main()
{
MyDataType d = (MyDataType)5;
int Five = (int)d;
Console.WriteLine(Five);
}
}
|