Hey guys,
I meant to ask this awhile ago, and since forgot the specific code (sorry about that), but the question is pretty simple: How would you call static/class methods?
For example, let's say I want to use Convert.ToInt32 in my code (a dumb example, I know, cuz AHK handles stuff like this automagically ). You don't create an instance of the Convert class, you just call ToInt32 on the class. In fact I'm pretty sure if your C# code contains "new Convert();" you'll get an error, because that's not how that class was meant to be used.
But the documentation on CLR.ahk didn't seem to address that scenario. I remember there was a CLR_CreateObject function (again, I probably didn't get that exactly right, sorry) which I understood to be equivalent to instantiating an object. Or am I wrong about that? Thanks.
CLR.ahk question
Re: CLR.ahk question
There are two ways to call static methods:
The CLR.ahk documentation only addresses functionality that CLR.ahk provides. It does not provide any helpers for calling static methods; that must be done using the standard interfaces that .NET provides (via COM callable wrappers).
You are correct about CLR_CreateObject; it is equivalent to new, and therefore irrelevant.
- Use .NET code (e.g. compile some C#).
- Use Reflection via COM.
The CLR.ahk documentation only addresses functionality that CLR.ahk provides. It does not provide any helpers for calling static methods; that must be done using the standard interfaces that .NET provides (via COM callable wrappers).
You are correct about CLR_CreateObject; it is equivalent to new, and therefore irrelevant.
Re: CLR.ahk question
Interesting. Guess I'll have to see how you did it in CLR.ahk itself. Thanks for the info.
Re: CLR.ahk question
Code: Select all
myCode =
(
using System;
using System.Windows.Forms;
class myClass
{
public void myMethod()
{
var myCharacter = '가';
MessageBox.Show(
myCharacter.ToString() +"\n"+
Convert.ToInt32(myCharacter));
}
}
)
myReference =
( Join|
System.dll
System.Windows.Forms.dll
mscorlib.dll
)
CLR_CreateObject(CLR_CompileC#(myCode, myReference), "myClass").myMethod()
Who is online
Users browsing this forum: No registered users and 274 guests