第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

正在回答

4 回答

public static“?explicit” operator Cat(Dog dog)

0 回復(fù) 有任何疑惑可以回復(fù)我~

改成隱士轉(zhuǎn)換

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

烏薪王 提問者

沒有用啊,上面改成implicit,下面去掉(Cat)
2018-11-04 回復(fù) 有任何疑惑可以回復(fù)我~

輸出:我叫hommy

????????? wow

????????? 我叫

????????? meow



0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

烏薪王 提問者

我自己來解釋一下把,形參不是字段
2018-11-06 回復(fù) 有任何疑惑可以回復(fù)我~

using System;

namespace 裝箱與拆箱
{?? abstract public class pet
??? {
??????? public string name;
? ? ? ??
??????? public pet(string name)
??????? {
??????????? Console.WriteLine("我叫" + name);
??????? }
??????? abstract public void speak();
???????
??? }
??? public class Dog : pet
??? {
??????? public Dog(string name):base(name)
??????? {
??????????
??????? }
???????
??????? public override void speak()
??????? {
??????????? Console.WriteLine("wow");
??????? }
??????? public static explicit operator Cat(Dog dog)
??????? {
??????????? return new Cat(dog.name);
??????? }
??? }
??? public class Cat : pet
??? {
??????? public Cat(string name) : base(name)
??????? {

??????? }
??????? public override void speak()
??????? {
??????????? Console.WriteLine("meow");
??????? }
???????
??? }
???
??? class Program
??? {
??????? static void Main(string[] args)
??????? {
? ? ? ? ? ? Dog dog = new Dog("hommy");
??????????? dog.speak();
??????????? Cat cat = (Cat)dog;
??????????? cat.speak();
? ? ? ? ? ??
??????? }
??? }
}


0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消

為什么我原來的構(gòu)造方法沒有了

我要回答 關(guān)注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號