hallo,
I have a function which takes 2 values as input and i want to return that 2 values, so how should write the return statement to return 2 values of String array. I also i should retrieve these values in a button click event. here is my code. -
public String newop(string userna,string pwd)
-
{
-
cwe_pro.GetFolderContentRequestType preq = new cwe_pro.GetFolderContentRequestType();
-
cwe_pro.GetFolderContentReplyType pres = new cwe_pro.GetFolderContentReplyType();
-
try
-
{
-
preq.depth = 0;
-
preq.folderId = docid;
-
ws.Url = "http://www.cwe-projects.eu/bscw/bscw.cgi";
-
ws.Credentials = new System.Net.NetworkCredential(userna, pwd);
-
pres = ws.GetFolderContent(preq);
-
XmlDocument doc = new XmlDocument();
-
doc.LoadXml(pres.folderContent);
-
XmlNodeList ni = doc.GetElementsByTagName("dcterms:modified");
-
st = ni[0].InnerText;
-
if (st.Equals(lmod))
-
{
-
-
MessageBox.Show("No modification In the File");
-
textBox3.Visible = false;
-
groupBox3.Visible = true;
-
-
}
-
else
-
{
-
-
MessageBox.Show("Last modified by another user :" + st);
-
textBox3.Visible = false;
-
groupBox3.Visible = true;
-
-
-
}
-
}
-
catch (Exception e1)
-
{
-
MessageBox.Show(e1.ToString());
-
-
return;
-
}
-
}
-
-
this is my function and how should write the return statement that return a array of those two values username and pwd. i have retreive these 2 values usrname and pwd in button click event.
-
-
private void button3_Click(object sender, EventArgs e)
-
{
-
}
-
sorry iam newbie to c# i dont know this simple task itself. any idea ?..
Thank you.
Dinesh.
5 1381
You could use "out" parameters. You declare two parameters and mark them with the keyword "out", then make sure you assign them before the end of the method: - public void newop(string userna, string pwd, out string resultString1, out string resultString2)
-
{
-
// make sure you assign the results to the two Out parameters before the method exits
-
resultString1 = result1;
-
resultString2 = result2;
-
}
You would then call the method like this: - public void Test()
-
{
-
string result1;
-
string result2;
-
newop("user", "pass", out result1, out result2);
-
}
Result1 and result2 now contain your return values.
Alternatively, if you really want, you can return the results in a generic list (or another collection type): - public List<string> newop(string userna,string pwd)
-
{
-
List<string> results = new List<string>();
-
results.Add(string1);
-
results.Add(string2);
-
return results;
-
}
The last return would need to be
The last return would need to be
Thanks r035198x, must have missed that. I've corrected the code sample.
Thanks r035198x, must have missed that. I've corrected the code sample.
No problem.
r035198x <-----Nitpicky .NET village idiot who knows nothing about .NET
You could use "out" parameters. You declare two parameters and mark them with the keyword "out", then make sure you assign them before the end of the method: - public void newop(string userna, string pwd, out string resultString1, out string resultString2)
-
{
-
// make sure you assign the results to the two Out parameters before the method exits
-
resultString1 = result1;
-
resultString2 = result2;
-
}
You would then call the method like this: - public void Test()
-
{
-
string result1;
-
string result2;
-
newop("user", "pass", out result1, out result2);
-
}
Result1 and result2 now contain your return values.
Alternatively, if you really want, you can return the results in a generic list (or another collection type): - public List<string> newop(string userna,string pwd)
-
{
-
List<string> results = new List<string>();
-
results.Add(string1);
-
results.Add(string2);
-
return results;
-
}
HI nuke ,
Thank you for ur reply. It work fine.
Dinesh.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Danny |
last post by:
HI again
Is there a nifty function in access that will:
1. return the amount of occurances of a small string within a larger
string?
this<br>is<br>a<br>test
would return 3 for <br>
|
by: Tom Warren |
last post by:
I found a c program called similcmp on the net and converted it to vba
if anybody wants it. I'll post the technical research on it if there
is any call for it. It looks like it could be a useful...
|
by: al |
last post by:
char s = "This string literal";
or
char *s= "This string literal";
Both define a string literal. Both suppose to be read-only and not to be
modified according to Standard. And both have...
|
by: songkv |
last post by:
Hi,
I am trying to reassign an array of char to a string literal by
calling a function.
In the function I use pointer-to-pointer since I want to reassign the
"string array pointer" to the string...
|
by: Goh, Yong Kwang |
last post by:
I'm trying to create a function that given a string, tokenize it and
put into a dynamically-sized array of char* which is in turn also
dynamically allocated based on the string token length.
I...
|
by: Simon Schaap |
last post by:
Hello,
I have encountered a strange problem and I hope you can help me to
understand it. What I want to do is to pass an array of chars to a
function that will split it up (on every location where...
|
by: Nascimento |
last post by:
Hello,
How to I do to return a string as a result of a function.
I wrote the following function:
char prt_tralha(int num)
{
int i;
char tralha;
|
by: Bob |
last post by:
I have a function that takes in a list of IDs (hundreds) as input parameter
and needs to pass the data to another step as a comma delimited string. The
source can easily create this list of IDs in...
|
by: Pascal |
last post by:
hello and soory for my english
here is the query :"how to split a string in a random way"
I try my first shot in vb 2005 express and would like to split a number in
several pieces in a random way...
|
by: Andrea |
last post by:
Hi,
suppose that I have a string that is an hexadecimal number, in order
to print this string I have to do:
void print_hex(unsigned char *bs, unsigned int n){
int i;
for (i=0;i<n;i++){...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |