{RESOLVED} Function output parameter ... ?
:wave: Hello....
How should i return a value from a function parameter ?
if in old VB version, i use "byref" in declaring a procedure / function parameter.
e.g :
Code:
private sub Testing(byval str1 as string, byref str2 as string)
str2 = str1 & "...just testing"
end sub
private sub command1_click()
dim tmpStr as string
call Testing("123", tmpstr)
msgbox(tmpstr)
end sub
then the str2 will function as the output parameter.
How should I do that in C# ? and how should i return the value from that output parameter.... ?
Thanks,
Re: Function output parameter ... ?
The better way would be to have a function that has a return value.
Code:
private string Testing(string str1)
{
return str1 + ".... just testing";
}
You can also use ref keyword to pass value types by reference, but here I would say just use a simple function that returns a value.
Re: Function output parameter ... ?
Thanks.
I've tried and it works....
Re: {RESOLVED} Function output parameter ... ?
you could also use out as followed;
Code:
void Button1Click(object sender, EventArgs e)
{
string outPut;
this.Test("THIS IS A TEST", out outPut);
MessageBox.Show(outPut);
}
void Test(string text, out string text2)
{
text2 = text + " Hello";
}
Hope this helps!!
:wave: :thumb: :wave: