I’ve a Document class which has two overloads taking one parameter each (String and Stream). Why can’t I use the following code to initialize Document class using Generics?
public abstract class PdfDocumentEditBaseService<T> : IDocumentEditService<T>
public T Rotate(T file, int pageNumber, float angle)
{
Document document = new Document(file); // cannot convert from 'T' to 'Stream'
document.Pages[pageNumber].Rotation = (RotationMode)angle;
document.SavePage(pageNumber);
return file;
}
I see a few suggestions to require T to inherit from Stream. And that will work. But, if your T really is always a stream, why not just remove the generic parameter and build that class like this: