I'm working with a task specific .NET plattform, which is precompiled and not OpenSource. For some tasks I need to extend this class, but not by inheriting from it. I simply want to add a method.
At first I want to show you a dummycode existing class:
public class Matrix<T> where T : new() {
...
public T values[,];
...
}
I want to extend this class in the following way:
public static class MatrixExtension {
public static T getCalcResult<T>(this Matrix<T> mat) {
T result = 0;
...
return result;
}
}
I've got this syntax from many google links so no idea whether it is correct. The compiler tells me no error, but in the end it doesn't work. In the end I want to call this function in the following way:
Matrix<int> m = new Matrix<int>();
...
int aNumber = m.getCalcResult();
So anyone got an idea? Thank you for your help!
Regards Nem