GetWindowWithRect from JS to C# not work?

Hi every body, I got this problem:

I’m trying to make a floating window fixed size with C#, already made one with JS, something like this:

// JavaScript MYWindow EditorWindow
static function Init() {
    var window : MyWindow = EditorWindow.GetWindowWithRect(Rect,Utility,String);
}
----

That works fine, but this:

----
// C# MyWindow EditorWindow
public static void Init() {
    MyWindow window = (MyWindow)EditorWindow.GetWindowWithRect<MyWindow>(Rect,Utility,String);
}
----

End with this error:

Expression denotes a ‘type’, where a ‘variable’, ‘value’ or ‘method group’ was expected.

Any one can tell me what’s wrong, I really don’t get it, I tried several ways but still does not work, even checked the manual and there is no example of how to do it with C#, I do not know if this is my mistake or there is no such option in C #, so, any comment will be welcome.

I only ask one favor, if they have not done this kind of code abstain from giving a bad review or a comment useless.

Thanks in advance.

I’m pretty sure your problem is that in UnityScript you can just use the class name where a System.Type object is required. Like karl said, your problem is probably in your parameters and like syclamoth said, you have to use typeof(classname) to get the System.Type object that describes this type. But without your actual parameters it’s all just guessing.

However your piece of code looks already strange. When you use the generic version of GetWindowWithRect you don’t need to cast it to Mywindow. Also keep in mind that the generic version doesn’t need the type parameter like the normal version. Two examples:

// C#
MyWindow window = EditorWindow.GetWindowWithRect<MyWindow>(new Rect(XXXX));
// or the "normal" verion:
MyWindow window = (MyWindow)EditorWindow.GetWindowWithRect(typeof(MyWindow), new Rect(XXXX));

these two versions are also possible in Unityscript:

// UnityScript
var window : MyWindow = EditorWindow.GetWindowWithRect.<MyWindow>(Rect(XXXX));
// or the "normal" verion:
var window : MyWindow = EditorWindow.GetWindowWithRect(MyWindow, Rect(XXXX));