关于=的重载
在某本参考书上看到 = 符号是可以重载的,求大神帮忙看一下这段代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Test
{
class Program
{
static void Main(string []args)
{
EqualClass equalstr = "重载“=”运算符";
string str = equalstr;
Console.Write(str);
Console.Read();
}
class EqualClass
{
private string _str;
private EqualClass(string str)
{
this._str = str;
}
public static implicit operator EqualClass(string str)
{
return new EqualClass(str);
}
public static implicit operator string(EqualClass mystr)
{
return mystr._str;
}
}
}
}