PassionateDeveloper
PassionateDeveloper

Reputation: 15138

Convert a method from java to C#.net

I have a method in Java:

public int getInt() {
IntByReference ibr = new IntByReference();
if (CFLib.INSTANCE.CFNumberGetValue(this, 4, ibr))
  return ibr.getValue();
return -1;  }

here is the Reference:

http://developer.apple.com/iphone/library/documentation/CoreFoundation/Reference/CFNumberRef/Reference/reference.html

How I Can copy this exactly for C#.net?

Upvotes: 0

Views: 266

Answers (1)

Gunslinger47
Gunslinger47

Reputation: 7061

That 4 there corresponds to the enum value kCFNumberSInt64Type. Why was that being jammed into a (32 bit) integer? Anyway, it looks like CFNumberGetValue wants a void* (C++) for its third parameter.

public int getInt() {
    int i;
    if (CFLib.INSTANCE.CFNumberGetValue(this, kCFNumberSInt32Type, (IntPtr)i))
        return i;
    return -1;
}

I don't know if anything needs to be done with the first parameter as I have no idea what this is.

Upvotes: 1

Related Questions