hi there,
I'm trying to call a third-party DLL, written in VB, from an app written in C#.
One of the methods I need to call is in the format:
records.populate(ref clientID, ref datefrom, ref dateto, ref status)
(where clientID and status are both integers and the other two are datetimes)
In the documentation for the library, it states that all the attributes are optional, giving the example:
records.populate(123,,,)
How can I emulate this code in C#?
I've tried the same syntax (won't compile with empty arguments); tried
using null for each one (well, I can't do this because DateTime is
non-nullable); tried using new int()/DateTime(), but this didn't return
any data when it should have.
So how do I do it?
I have no idea how the populate() method is handling the arguments, since it's third-party.
Thanks for your help.
Empty attributes in C#?
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

AlanRank #669 · 3.6K reputationPosted Aug 6, 2007, 8:35 AM EDT
Try this:
object optional = Type.Missing;
records.populate(123, ref optional, ref optional, ref optional);
Fiona8 reputationPosted Aug 6, 2007, 8:41 AM EDT
Cannot convert from "ref object" to "ref int"
:s
AlanRank #669 · 3.6K reputationPosted Aug 6, 2007, 8:51 AM EDT
As those arguments are optional, they must have default values which the function uses when they're not used in the call. The problem, in the absence of any documentation, is to guess what they are :)
You could try this:
DateTime datefrom = DateTime.Now;
DateTime dateto = DateTime.Now;
int status = 0;
records.populate(123, ref datefrom, ref dateto, ref status);