Delphi 2010 - Why can't I declare an abstract method with a generic type parameter?

Posted by James on Stack Overflow See other posts from Stack Overflow or by James
Published on 2010-03-23T15:13:01Z Indexed on 2010/03/23 15:13 UTC
Read the original article Hit count: 147

I am trying to do the following in Delphi 2010:

TDataConverter = class abstract
public
    function Convert<T>(const AData: T): string; virtual; abstract;
end;

However, I keep getting the following compiler error:

E2533 Virtual, dynamic and message methods cannot have type parameters

I don't quite understand the reason why I can't do this. I can do this in C# e.g.

public abstract class DataConverter
{
    public abstract string Convert<T>(T data);
}

Anyone know the reasoning behind this?

© Stack Overflow or respective owner

Related posts about delphi

Related posts about delphi-2010