Start a new topic
Answered

Object.As<T> function

What are you doing in your Object.As<T>() functions to do the casting.


Can you please list that code. I wanna give that general .As<T> casting to 

my JQueryResult objects


Best Answer

There is no code behind As<T> actually, DuoCode compiler simply omits this special "extension-method" call that's it.

But you still can use generic on extern methods (see qunit.d.cs in UnitTest template), for example there you have:

  

public static extern void equal<T>(T actual, T expected);

  


When calling such method the <T> is auto-omitted by DuoCode compiler, since this method is extern.

Try to combine it with where keyword, see also:

 

Document.getElementById<T>(string elementId) where T : HTMLElement;

 



1 Comment

Answer

There is no code behind As<T> actually, DuoCode compiler simply omits this special "extension-method" call that's it.

But you still can use generic on extern methods (see qunit.d.cs in UnitTest template), for example there you have:

  

public static extern void equal<T>(T actual, T expected);

  


When calling such method the <T> is auto-omitted by DuoCode compiler, since this method is extern.

Try to combine it with where keyword, see also:

 

Document.getElementById<T>(string elementId) where T : HTMLElement;

 



Login or Signup to post a comment