Skip to content

How to call methods with Type arguments? #506

Discussion options

You must be logged in to vote

Hi @handerss-tibco,

I guess this happens since ClearScript thinks I'm trying to call a generic method.

Not quite. Consider this line in your code:

engine.Execute(@"obj.DoSomethingWithType(System.String.Type);");

.NET's String class has no static property named "Type", so the JavaScript expression System.String.Type evaluates to undefined, which isn't a valid argument for DoSomethingWithType.

What is the way to call these types of methods?

In the JavaScript environment, System.String is a host type; it isn't a Type object. A host type is a special object that enables C#-like syntax and capabilities.

Suppose you wanted to call DoSomethingWithType in C#. The following wouldn't work:

obj.D…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@handerss-spotfire
Comment options

Answer selected by handerss-spotfire
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants