Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Properties in Interfaces
//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(); } class B:IA { private int Z; public B() { } public int ID { get { Console.WriteLine("Implement Property ID in B"); return Z; } set{Z=value;} } public void B_Method() { Console.WriteLine("B Method"); } public void A_InterFace1() { Console.WriteLine("Implement Interface1 in B"); } public void A_InterFace2() { Console.WriteLine("Implement Interface2 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(); 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(); b.ID=25; int i=b.ID; Console.WriteLine("ID from B: "+i); } } }
run
|
edit
|
history
|
help
0
Test equality...1
Project Euler No 2
Funzpoint
Hello World
Check if string is palindrome
Swap adjacent Elements
string + null
3
tool
Convert String to Pig Latin