Hello maicalal,
That's correct. Many generic methods don't require explicit type arguments because their type arguments can be inferred from their other arguments. In this case there are no other arguments, so type inference is impossible and an explicit type argument is required.
Here's a simple example:
and then:
In general, to invoke a method that requires explicit type arguments, place the required number of host types at the beginning of the argument list.
Cheers!
One way could be to add a host type and pass it to the generic method ?
That's correct. Many generic methods don't require explicit type arguments because their type arguments can be inferred from their other arguments. In this case there are no other arguments, so type inference is impossible and an explicit type argument is required.
Here's a simple example:
publicclass Factory { public T Create<T>() where T : new() { returnnew T(); } } publicclass SomeClass { // ... }
engine.AddHostObject("factory", new Factory()); engine.AddHostType("SomeClass", typeof(SomeClass)); engine.Execute("obj = factory.Create(SomeClass)");
Cheers!