The generic type uses the interface and the interface uses the type. Is that the cause of this problem? The lines that emit compile errors are marked below. Is there a simple fix?
using System;
using System.Collections.Generic;
namespace CcelBookParse.Utility
{
public interface IListType
{
void Initialize(ParseListManager<IListType> value); // Error.
}
public class ParseListManager<IListType> : List<IListType> where IListType : new()
{
private int NextIndex;
public ParseListManager() { }
protected void Initialize()
{
NextIndex = 0;
}
protected IListType GetNext()
{
IListType Result;
if (Count < NextIndex)
{
Result = this[NextIndex];
Result.Initialize(this); // Error.
}
else if (Count == NextIndex)
{
Result = new IListType();
Add(Result);
}
else
{
throw new Exception("List allocation index error.");
}
return Result;
}
}
}
IListTypeIListTypeand the interfaceIListType. Can you please try to use something likeTas generic type?