G'day everyone,
I was just curious as to whether Visual Studio has a package that will generate default methods for a class that is either extending a super class with abstract methods or an interface with said methods (similar to Eclipse with Java)?
i.e. if you had
namespace Math2 {
interface Number {
T add(T args);
T subtract(T args);
T multiply(T args);
T divide(T args);
}
}
|
and you create a class which implements the interface i.e.
namespace Math2 {
class ComplexNumber : Number {
}
}
|
it would generate default methods, i.e.
namespace Math2 {
class ComplexNumber : Number {
public ComplexNumber add(ComplexNumber args) {
return null;
}
public ComplexNumber subtract(ComplexNumber args) {
return null;
}
public ComplexNumber multiply(ComplexNumber args) {
return null;
}
public ComplexNumber divide(ComplexNumber args) {
return null;
}
}
}
|
is that possible? (I'm gotten quite lazy with Java in Eclipse!)
Thanks in Advance,
David
Jaish MathewsPosted Jul 17, 2010, 1:00 PM
You can use the "Implement Interface" context menu. Just right click on inherited interface and you will get this menu. This menu will generate the whole method body. Please look the attached screen shot.