암묵적인 형변환? 코드...?
어쨌든... 굵은 글씨를...
훈스에 김시원님이 강좌에 개나소나...로 써주셨던.. 난 몰랐던... ㅠㅠ;
찾아보니.. 아래처럼 되는것? 같은... 글이었음.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
SomeType st = 0;
int i = st;
}
}
class SomeType
{
object _obj = 0;
public object Value
{
get { return _obj; }
private set { _obj = value; }
}
public SomeType(object obj)
{
_obj = obj;
}
public static implicit operator SomeType(int typ)
{
try
{
return new SomeType(typ);
}
catch(Exception ex ) {
throw ex;
}
}
public static implicit operator int(SomeType typ)
{
try
{
checked
{
return (int)typ.Value;
}
}
catch (Exception ex)
{
throw ex;
}
}
}