How to: Implement Interface
Use this procedure to perform the Implement Interface IntelliSense operation. For more information, see Implement Interface.
To implement an interface in C# with explicit declarations using IntelliSense.
Create a console application. For more information, see Building Console Applications.
Place the cursor after the class Program declaration.
Type : IComparable so the declaration becomes class Program : IComparable.
Activate the smart tag under IComparable. The following two options will appear:
Implement interface 'IComparable'.
Explicitly implement interface 'IComparable'.
Choose Explicitly implement interface 'IComparable'.
IntelliSense then adds an IComparable.CompareTo method from the IComparable interface to the Program class:
#region IComparable Members
int IComparable.CompareTo(object obj)
{
throw new Exception("The method or operation is not implemented.");
}
#endregion
To implement an interface in C# with implicit declarations using IntelliSense.
Create a console application. For more information, see Building Console Applications.
Place the cursor after the class Program declaration.
Type : IComparable so the declaration becomes class Program : IComparable.
Activate the smart tag under IComparable. The following two options will appear:
Implement interface 'IComparable'.
Explicitly implement interface 'IComparable'.
Choose Implement interface 'IComparable'.
IntelliSense will then add a CompareTo method from the IComparable interface to the Program class:
#region IComparable Members
public int CompareTo(object obj)
{
throw new Exception("The method or operation is not implemented.");
}
#endregion
To implement an interface in J# using IntelliSense
Create a J# console application.
Open the .jsl file, and under the package statement, add import System.*.
Place the cursor after the class Program statement, and type implements IComparable so the statement becomes class Program implements IComparable.
Activate the SmartTag under IComparable and choose Implement interface System.IComparable stubs.
IntelliSense adds an IComparable.CompareTo method from the IComparable interface to the Program class:
#region IComparable Members
public int IComparable.CompareTo(object obj)
{
throw new System.NotImplementedException();
}
#endregion
See Also
Reference
Interfaces (C# Programming Guide)
Explicit Interface Implementation (C# Programming Guide)