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

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
 
K

Klaas

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);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top