C # and vb.net

xiaoxiao2021-03-06  42

Interface [Public | Protected | Private] interface interface interfacname {// DELEGATE} When the interface is implemented, the interface name and unidentified distinguished distinguished distortion EG: public Interface iMyshow {void show ();} public class myshow: iMyShow {public void show () // must write forward PUBLIC if write void show () error {System.Console.write ("without interface name"); }}} Public class mymain {public static void main () {// Using class definition reference myshow obj = new myshow (); obj.show (); // interface reference method iMyShow Obj2 = new myshow (); obj2.show ();}} // Take the interface name public interface iMyshow {system.console.write ("with interface name");} public class myshow: iMyShow {void iMyshow.show () // No limit word in front of any qualifier { System.console.write ("with interface name");}} public class mymain {myshow obj = new myshow (); obj.show (); // illegally after adding limited words, This method is a reference to the special item, which can only have an interface to reference iMyShow obj2 = new myShow (); obj2.show ();

}} I want to leave a problem for the hobby of C #. Please everyone together to talk about public interface IMyShow {void Show ();} public interface IMyShow2 {void Show ();} public class Myclass: IMyShow, IMyShow2 {public Myclass () {} void IMyShow.Show () {System.Console .Write ("iMyshow");

}

Public void show () {system.console.write ("myclass show");}

Void iMyshow2.show () {system.console.write ("iMyshow2.show ()");

// Todo: Add myclass.show implementation}

}

Class class1 {///

/// The primary entry point of the application. /// [stathread] static void main (string [] args) {iMyshow obj2 = new myclass (); obj2.show (); iMyShow Obj1 = new myclass (); obj1.show (); myclass obj = new myclass (); obj.show ();}}}

Namespace WFGSPACE PUBLIC Interface ImiShow Sub show () Function Add (Byval A As Integer) AS Integer

End Interface Public Interface IMyShow2 Sub Show () Function Add (ByVal a As Integer, ByVal b As Integer) As IntegerEnd Interface Public Class MyCls: Implements IMyShow, IMyShow2 Private iValue As Integer

Sub show () Implements IMYSHOW.SHOW System.console.write ("WFNG Fu Guo") End Sub SHOW2 () Implements Implement IMYSHOW2.SHOW System.Console.write ("WFG")

End Sub Function Add2 (Byval A As Integer, BYVAL B AS Integer) AS Integer Implements IMYSHOW.ADD, IMYSHOW2.ADD

iValue = a b

System.console.writeline ("{0} {1} = {2}", a, b, ivalue) End Function End Class Public Class Common Public Shared Sub Main () DIM OBJ AS Mycls = New Mycls Dim Obj2 As iMYSHOW = New mycls Dim obj3 as iMyShow2 = new mycls system.console.writeline ("class mycls object") obj.show2 () obj.add2 (5, 4)

System.console.writeline ("Interface Imyshow Object") Obj2.show () obj2.add (5, 4) system.console.writeline ("Interface ImiShow2 Object") Obj3.show () obj3.add (5, 4)

End Sub End Class

End Namespace

转载请注明原文地址:https://www.9cbs.com/read-71490.html

New Post(0)