David Galea

David Galea

  • NA
  • 12
  • 0

Visual Studio Interfaces

Jul 15 2010 6:01 AM
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> {
        
        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<ComplexNumber> {

    }
}

it would generate default methods, i.e.
 namespace Math2 {
    class ComplexNumber : Number<ComplexNumber> {

        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


Answers (1)