Anyone can help`
I need to have a generic method which in C++/CLI.
I try the following at the moment:
generic<K, ref class U>
void OnUpdate (
K key,
U update
);
Sadly it does not work. The method must 开发者_StackOverflow中文版accept K and U, and the C# definitions are:
void DataUpdate<K, U>(DataUpdate<K, U> update) where U : class;
(yes, the method is different - OnUpdate will check whether apoint to an interface has set, then call this method in the interface, like an event handler, so the parameters must match).
The generic syntax in C++/CLI eludes me. I have no problem defining K also to be a class.
It is not that clear exactly what you are looking for. Constraints must be declared with the where keyword:
generic<typename K, typename U>
where U : ref class
void OnUpdate (K key, U update)
{
// etc..
}
精彩评论