I tried code below in .NET 3.5 but got exception at line shown in comment:
Cannot convert type 'TUnpaid' to 'ClassLibrary1.Unpaid'
How to fix this in .NET 3.5 ?
namespace ClassLibrary1
{
public class EntityBase
{
public virtual void Save<T>(T dok) where T : EntityBase, new()
{
}
}
public class Unpaid : EntityBase
{
public override void Save<TUnpaid>(TUnpaid dok)
{
// Cannot convert type 'TUnpaid' to 'ClassLibrary1.Unpaid'
var kup = (Unpaid)dok;
}
}
}
You either should write an operator of type conversion, or write a method (or class) which establishes the connections between two types.
In your code sample you use the two different types (
TUnpaidandUnpaid) with no connection between them.