Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Interface fully qualified names
//Title of this code //Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { interface IA { int ID { get; set; } void A_InterFace1(); void A_InterFace2(); } interface IB { int ID { get; set; } void B_InterFace1(); void B_InterFace2(); } class B:IA,IB { private int Z,Y; public B() { } int IA.ID { get { Console.WriteLine("Implement Property ID from IA in B"); return Z; } set{Z=value;} } public void B_Method() { Console.WriteLine("B Method"); } void IA.A_InterFace1() { Console.WriteLine("Implement Interface1 from IA in B"); } public void A_InterFace2() { Console.WriteLine("Implement Interface2 from IA in B"); } int IB.ID { get { Console.WriteLine("Implement Property RN from IB in B"); return Y; } set{Y=value;} } void IB.B_InterFace1() { Console.WriteLine("Implement Interface1 from IB in B"); } public void B_InterFace2() { Console.WriteLine("Implement Interface2 from IB in B"); } } class C:IA { private int X; public C() { } public int ID { get { Console.WriteLine("Implement Property ID in C"); return X; } set{X=value;} } public void C_Method() { Console.WriteLine("C Method"); } public void A_InterFace1() { Console.WriteLine("Implement Interface1 in C"); } public void A_InterFace2() { Console.WriteLine("Implement Interface2 in C"); } } public class Program { public static void Main(string[] args) { IA b=new B(); B b1=new B(); //b1.A_InterFace1();//not accessable since A_Interface1 is fully qualified b.A_InterFace1(); IA c=new C(); b.A_InterFace1(); // b.B_Method();//No B's method is accessable from IA's reference variable as it knows only IA's methods. c.A_InterFace1(); //b1.ID=100; b.ID=25; //c.ID=50; C c1=new C(); c1.ID=500; Console.WriteLine("ID from B: "+b.ID); Console.WriteLine("ID from C: "+c1.ID); } } }
run
|
edit
|
history
|
help
0
an attempt at making a usable code thing (failed lol)
2 point gradient (v2)
19.05.2020
Captcha
Day1
EX8 Loop_For_While
Insertion Sort
asdfghyjujn dsc
f
Liczba powtórzająca