I've asked this question before but I don't think I explained myself clearly so I'm going to try again.
I have the below code;
public interface IDocumentMerger
{
List<???????> Process();
}
public class EmailMerger : IDocumentMerger
{
public void Process()
{
return new List<MailMessage>();
}
}
public class DocumentMerger<T> where T : IDocumentMerger
{
public T objMerger;
public DocumentMerger()
{
Type t = typeof(T);
objMerger = (T)Activator.CreateInstance(t);
}
public List<???????> Process()
{
return objMerger.Process();
}
}
I want to use the above something like this;
DocumentMerger<EmailMerger> merger = new DocumentMerger<EmailMerger>();
List<MailMessage> messages = merger.Process();
DocumentMerger<SmsMerger> merger = new DocumentMerger<SmsMerger>();
List<SmsMessage> messages = merger.Process();
But I can't figure out how to return either a list of type MailMessage or a list of type SmsMessage depending on whether I create a DocumentMerger passing int either MailMerger or SmsMerger.