c#自定义类型的转换方式operator,以及implicit(隐式)和explicit (显示)声明

https://docs.microsoft.com/zh-cn/dotnet/csharp/language-reference/keywords/explicit

https://docs.microsoft.com/zh-cn/dotnet/csharp/language-reference/keywords/implicit

https://docs.microsoft.com/zh-cn/dotnet/csharp/language-reference/keywords/operator

Vector2隐匿转换例子

public struct Vector2 {
public static implicit operator Vector2(Vector3 v){
return new Vector2(v.x,v.y);
} public static implicit operator Vector3(Vector2 v){
return new Vector3(v.x,v.y,);
}
}
上一篇:Axure谷歌浏览器Chrome扩展程序下载及安装方法


下一篇:iOS APNS远程推送(史上最全步骤)