I am using contactsreader.dll
to import my Gmail contacts. One of my method has the out
parameter. I am doing this:
Gmail gm = new Gmail();
DataTable dt = new DataTable();
string strerr;
gm.GetContacts("[email protected]", "******", true, dt, strerr);
// It gives invalid arguments error..
And my Gmail class has
public void GetContacts(string strUserName, string strPassword,out bool boolIsOK,
out DataTable dtContatct, out string strError);
Am I passing the correct values for out
parameters?
C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...
Compared to other languages—like Java, PHP, or C#—C is a relatively simple language to learn for anyone just starting to learn computer programming because of its limited number of keywords.
What is C? C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories in 1972. It is a very popular language, despite being old. C is strongly associated with UNIX, as it was developed to write the UNIX operating system.
Full form of C is “COMPILE”. One thing which was missing in C language was further added to C++ that is 'the concept of CLASSES'.
You need to pass them as declared variables, with the out
keyword:
bool isOk;
DataTable dtContact;
string strError;
gm.GetContacts("[email protected]", "******",
out isOk, out dtContact, out strError);
In other words, you don't pass values to these parameters, they receive them on the way out
. One way only.
You have to put "out" when calling the method - gm.GetContacts("[email protected]", "******", out yourOK, out dt, out strerr);
And by the way, you don't have to do DataTable dt = new DataTable();
before calling.
The idea is that the GetContacts
method will initialize your out
variables.
Link to MSDN
tutorial.
Since the definition of your function
public void GetContacts(string strUserName, string strPassword, out bool boolIsOK, out DataTable dtContatct, out string strError);
requires that you pass some out
parameters, you need to respect the method signature when invoking it
gm.GetContacts("<username>", "<password>", out boolIsOK, out dtContatct, out strError);
Note that out
parameters are just placeholders, so you don't need to provide a value before passing them to the method. You can find more information about out
parameters on the MSDN website.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With