Re: Is there any way to hack around C#'s lack of support for optional arguments?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



>Is it totally fruitless to try to deal with optional arguments? Arguably,
>it's not even strictly an issue with arguments tagged as optional. I can
>imagine an interface that omits the OPTIONAL keyword but simply documents
>that NULL pointer values are acceptable. How can this condition (invalid
>references) be tested in C#?

The only way I can think of is to modify the interop assembly and
change the parameter types to IntPtr or int*. If you for example
change the plFlags type to int* (forcing you to use unsafe code in C#)
you can then write

if ( flags != null )
*flags = 123;



Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
.



Relevant Pages

  • Re: binary search
    ... ??>> int main ... C> I think these want to be 0 and 15, and the parameter types should ... but I doubt I'm passing array as parameter ... static const double power= { ...
    (comp.lang.c)
  • Re: Allocated memory
    ... > int size ... > int* buf ... that there are implementations where this ... And I can certainly imagine an implementation where each top-level ...
    (comp.lang.c)
  • Re: Allocated memory
    ... > int size ... > int* buf ... that there are implementations where this ... And I can certainly imagine an implementation where each top-level ...
    (comp.lang.cpp)
  • Re: Parameter Name Warning?
    ... the watch window showed different values for e and f than they ... > I realize that I could have defined the method as void M(int, int, int, int, ... the debugger could have helped. ... I cannot imagine it would do that. ...
    (microsoft.public.vc.language)
  • Re: What is wrong?
    ... You should declare, not define, functions in headers. ... The below belongs ... I can't imagine how you know that, being as you don't check printf's ... int mainis clearer. ...
    (comp.lang.c)