0

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?

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

The Problem is, there is no CFLib in C#, so i must find another method to do it. "This" is the value, which should be converted
If you're not going to use the Core Foundation library then just replace all CFNumber references and calls with equivalent C# primitives. It this case it looks like your entire class (whatever this is) should be replaced by an int (or long).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.