Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Interface fully qualified names
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//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); } } }
Show compiler warnings
[
+
]
Show input
Compilation time: 0.09 sec, absolute running time: 0.06 sec, cpu time: 0.06 sec, average memory usage: 16 Mb, average nr of threads: 4
edit mode
|
history
|
discussion