gpt4 book ai didi

c# - 有没有办法为重载运算符调用基本方法? C#

转载 作者:太空宇宙 更新时间:2023-11-03 21:31:28 25 4
gpt4 key购买 nike

 class x : y
{
public static bool x operator >(x i1, x i2)
{
// ****
}
}

是否可以从 **** 中的 y 类调用 >?如果是,怎么办?

最佳答案

x 向上转换为 y 然后你应该能够调用 y 的实现。

class x : y
{
public static bool x operator >(x i1, x i2)
{
bool greater = (y)i1 > (y)i2;
return whatever;
}
}

关于c# - 有没有办法为重载运算符调用基本方法? C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23968930/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com