简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM