R
ReneMarxis
Hello
I have some problem with events and generics. I'd like to raise an
event that inone generic class that has generic arguments:
//=====
public class PageStatusEventArgs<T> : EventArgs {
T _status;
public PageStatusEventArgs (T status) {
_status = status;
}
public T Status {
get { return (_status); }
}
}
public delegate void NewStatusEventHandler<T> (object sender,
PageStatusEventArgs<T> e);
public class PageStatus<T> {
public event NewStatusEventHandler< PageStatus<T>,
PageStatusEventArgs<T>> StatusChanged;
private T _status;
public T Status{
get { return _status; }
set {
//set the status
_status = value;
//and raise the event
StatusChanged(this, _status);
}
}
}
//=====
I get an error on
public event NewStatusEventHandler< PageStatus<T>,
PageStatusEventArgs<T>> StatusChanged;
I know why (because i have to define NewStatusEventHandler also as
<T>) but i don't know how or where to put that additional T
Can someone help please?
_thanks
I have some problem with events and generics. I'd like to raise an
event that inone generic class that has generic arguments:
//=====
public class PageStatusEventArgs<T> : EventArgs {
T _status;
public PageStatusEventArgs (T status) {
_status = status;
}
public T Status {
get { return (_status); }
}
}
public delegate void NewStatusEventHandler<T> (object sender,
PageStatusEventArgs<T> e);
public class PageStatus<T> {
public event NewStatusEventHandler< PageStatus<T>,
PageStatusEventArgs<T>> StatusChanged;
private T _status;
public T Status{
get { return _status; }
set {
//set the status
_status = value;
//and raise the event
StatusChanged(this, _status);
}
}
}
//=====
I get an error on
public event NewStatusEventHandler< PageStatus<T>,
PageStatusEventArgs<T>> StatusChanged;
I know why (because i have to define NewStatusEventHandler also as
<T>) but i don't know how or where to put that additional T
Can someone help please?
_thanks