//由于类是引用类型,对tmpPG1坐标修改后影响到了tmpPG3 PointGeometry tmpPG3 = tmpPG1; tmpPG1.X = 7; tmpPG1.Y = 8; tmpPG1.Z = 9; Console.WriteLine(tmpPG1); Console.WriteLine(tmpPG3); Console.ReadLine(); } } } 结果: X: 1, Y: 2, Z: 3 X: 4, Y: 5, Z: 6 X: 7, Y: 8, Z: 9 X: 7, Y: 8, Z: 9
17.接口的多继承会带来哪些问题?
答:
C# 中的接口与类不同,可以使用多继承,即一个子接口可以有多个父接口。但如果两个父成员具有同名的成员,就产生了二义性(这也正是 C# 中类取消了多继承的原因之一),这时在实现时最好使用显式的声明
示例:
using System; using System.Collections.Generic; using System.Text; namespace Example17 { class Program { //一个完整的接口声明示例 interface IExample { //属性 string P { get; set; } //方法 string F(int Value); //事件 event EventHandler E; //索引指示器 string this[int Index] {
上一篇:Photoshop直观调节反转负冲效果
下一篇:Javascript实现的自动验证函数
|