Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: Generic types

$
0
0
Hi Sybaris,

A JavaScript class (really just a function) cannot be used as a .NET type argument. As far as the managed side is concerned, it's just a script object and has no public runtime type beyond DynamicObject.

Therefore an instance of a JavaScript class, like any script object, can be stored in a managed collection of type DynamicObject, IDynamicMetaObjectProvider, or simply Object:
function MyClass() {
    this.MyValue = 10;
}
var list = new DotNet.System.Collections.Generic.List(DotNet.System.Object);
list.Add(new MyClass());
var test = list[0].MyValue; // test == 10
Thanks for your question, and good luck!

Viewing all articles
Browse latest Browse all 2297

Latest Images

Trending Articles





Latest Images