Argument '1': cannot convert from 'BaseObject<T>' to 'T'

  • Thread starter Thread starter Klaas
  • Start date Start date
K

Klaas

Hi All,

I have this piece of code :

public interface IBase<T>
where T : BaseObject<T>, IBase<T>
{
public DataRow ObjectToDataRow(T Source);
}

public class BaseObject<T>
where T : BaseObject<T>, IBase<T>
{
public virtual DataRow ObjectToDataRow(T Source) { return null; }

public void Add(T Object)
{ innerData.Rows.Add(ObjectToDataRow(Object)); }

public void Save()
{
if (theDataRow == null)
ObjectToDataRow(this);
}

}
In Save() when I want to call ObjectToDataRow(this); I get that compile
error.
Why? [this] is already the type BaseObject!!! :-s
I want in the override function ObjectToDataRow in T to fill itself...

tia
 
When I try this code I get:

Error 1 'T' is a 'type parameter' but is used like a 'variable'


public class BaseObject<T>

where T : BaseObject<T>

{



public virtual DataRow ObjectToDataRow(T Source) { return null; }



public void Save()

{

if (theDataRow == null)

ObjectToDataRow(T);
 
Back
Top