append(a,b,&result)
-
string result = ""; append("Ali","Salim",&result); public void append(string a, string b, string result) { result = a +" "+ b; } Error: Error 11 Argument '4': cannot convert from 'string*' to 'string' D:\app\pup\Code\TBrectangular.aspx.cs 23 262 D:\app\
-
string result = ""; append("Ali","Salim",&result); public void append(string a, string b, string result) { result = a +" "+ b; } Error: Error 11 Argument '4': cannot convert from 'string*' to 'string' D:\app\pup\Code\TBrectangular.aspx.cs 23 262 D:\app\
It's telling you that
result
and&result
are not the same thing. However, your publicvoid append(string a, string b, string result)
wouldn't do much anyway, since you can't modify function parameters without explicitly specifying.CQ de W5ALT
Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software
-
string result = ""; append("Ali","Salim",&result); public void append(string a, string b, string result) { result = a +" "+ b; } Error: Error 11 Argument '4': cannot convert from 'string*' to 'string' D:\app\pup\Code\TBrectangular.aspx.cs 23 262 D:\app\
this is the C# forum, your code does not compile here. :|
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
Prolific encyclopedia fixture proof-reader browser patron addict?
We all depend on the beast below.
-
string result = ""; append("Ali","Salim",&result); public void append(string a, string b, string result) { result = a +" "+ b; } Error: Error 11 Argument '4': cannot convert from 'string*' to 'string' D:\app\pup\Code\TBrectangular.aspx.cs 23 262 D:\app\
While in c++ that would work just fine, C# doesn't let you manage pointers or references directly without declaring a block of code
unsafe
(it might be worth it for you to look up the unsafe keyword and how to use it) What C# does give you for just this type of thing is another couple of keywords for your parameters,ref
andout
. Both will allow you to pass the reference to your string so that you can modify it inside the function, but there is one main difference. Using theout
keyword you can pass in an uninitialised variable that you expect the function to fill in. Theref
keyword will only allow you to pass in variables that have been initialised as it expects the function to use and modify it. So, for this type of thing you can simply use theout
keyword;string result;
append("Ali", "Salim", result);public void append(string a, string b, out string result)
{
result = a +" "+ b;
}Now, on a slightly different topic, if you plan on combining a lot of strings you may simply want to use the
StringBuilder
class, as it is a lot more efficient than simply adding two or more strings together.My current favourite word is: Smooth!
-SK Genius
-
string result = ""; append("Ali","Salim",&result); public void append(string a, string b, string result) { result = a +" "+ b; } Error: Error 11 Argument '4': cannot convert from 'string*' to 'string' D:\app\pup\Code\TBrectangular.aspx.cs 23 262 D:\app\
Or why not simply return the string like a normal person?
-
Or why not simply return the string like a normal person?
Now you surprise me. :laugh: :laugh:
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
Prolific encyclopedia fixture proof-reader browser patron addict?
We all depend on the beast below.