nullreferenceexception - F# passing null reference to ref parameter -


i using third party api rather clumsily makes use of ref parameters produce outputs. hate design of api it's have available me right now. i've had hide datatypes of api due proprietary code should irrelevant problem @ hand.

anyway in c# can pass null reference ref parameter follows:

            idatatype tl = null;             bool success = api.myfunction(ref tl); 

however in f# following not work

    let mutable tl : idatatype = null //null reference assignment in f#     let success = api.myfunction(&tl) //& means ref in f# 

it returns null reference exception error. no such error returned in c#.

has experiences before? thinking must bug in api relatively ancient design.

**edit: should closed, believe answer not lie in f# code in api it's number of known bugs similar this.

quick , dirty prototyping of api in c#

namespace api {     public interface idatatype { void hi(); }      public class api: idatatype {         public void hi() { system.console.writeline("hi!"); }          public bool myfunction(ref idatatype iface) {             iface = new api();             return true;         }     } } 

and using f# way while staying within same clr:

let mutable iface : api.idatatype = null if api.api().myfunction(&iface) iface.hi() 

works without problem.

so, indeed, problem specific given api , has nothing form of use f#.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -