[ACCEPTED]-C# equivalent of Java 'implements' keyword?-java
Accepted answer
public class MyClass implements LargerClass
In Java, this declares that MyClass
implements 9 the interface LargerClass
; that is, sets out implementations 8 for the behaviours defined in LargerClass
.
To inherit from 7 another class in Java, use extends
, e.g.
public class MyClass extends LargerClass
The C# equivalent, in 6 both cases, is specified as
public class MyClass : LargerClass
Since this syntax 5 doesn't make it clear whether or not LargerClass
is 4 an interface or another class being inherited, you'll 3 find C#/.NET developers adopt the convention 2 that interface names are prefixed with uppercase 1 "I", e.g. IEnumerable
.
public class MyClass : LargerClass
{
}
0
public class MyClass : LargerClass {...}
0
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.