Click here to Skip to main content
15,913,587 members
Home / Discussions / C#
   

C#

 
GeneralRe: Generate Error While Build Dll Pin
Anubhava Dimri6-May-10 21:43
Anubhava Dimri6-May-10 21:43 
GeneralRe: Generate Error While Build Dll Pin
Vimalsoft(Pty) Ltd6-May-10 21:56
professionalVimalsoft(Pty) Ltd6-May-10 21:56 
GeneralRe: Generate Error While Build Dll Pin
Anubhava Dimri6-May-10 22:16
Anubhava Dimri6-May-10 22:16 
GeneralRe: Generate Error While Build Dll Pin
Vimalsoft(Pty) Ltd6-May-10 22:31
professionalVimalsoft(Pty) Ltd6-May-10 22:31 
QuestionDataSet to List<> Pin
Illegal Operation6-May-10 17:43
Illegal Operation6-May-10 17:43 
AnswerRe: DataSet to List Pin
Luc Pattyn6-May-10 17:51
sitebuilderLuc Pattyn6-May-10 17:51 
GeneralRe: DataSet to List Pin
Illegal Operation6-May-10 17:55
Illegal Operation6-May-10 17:55 
GeneralRe: DataSet to List Pin
Luc Pattyn6-May-10 18:06
sitebuilderLuc Pattyn6-May-10 18:06 
GeneralRe: DataSet to List Pin
Illegal Operation6-May-10 18:09
Illegal Operation6-May-10 18:09 
GeneralRe: DataSet to List Pin
Luc Pattyn6-May-10 18:15
sitebuilderLuc Pattyn6-May-10 18:15 
Questionappend(a,b,&result) Pin
Abdul-Rhman Alsri6-May-10 14:03
Abdul-Rhman Alsri6-May-10 14:03 
AnswerRe: append(a,b,&result) Pin
Dr.Walt Fair, PE6-May-10 14:40
professionalDr.Walt Fair, PE6-May-10 14:40 
AnswerRe: append(a,b,&result) Pin
Luc Pattyn6-May-10 14:47
sitebuilderLuc Pattyn6-May-10 14:47 
AnswerRe: append(a,b,&result) Pin
Anthony Mushrow6-May-10 14:56
professionalAnthony Mushrow6-May-10 14:56 
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 and out. 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 the out keyword you can pass in an uninitialised variable that you expect the function to fill in. The ref 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 the out 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


AnswerRe: append(a,b,&result) Pin
PIEBALDconsult6-May-10 15:02
mvePIEBALDconsult6-May-10 15:02 
GeneralRe: append(a,b,&result) Pin
Luc Pattyn6-May-10 15:24
sitebuilderLuc Pattyn6-May-10 15:24 
Questionkey_down event fired twice Pin
igalep1326-May-10 11:18
igalep1326-May-10 11:18 
AnswerRe: key_down event fired twice Pin
William Winner6-May-10 11:23
William Winner6-May-10 11:23 
GeneralRe: key_down event fired twice Pin
igalep1326-May-10 11:26
igalep1326-May-10 11:26 
GeneralRe: key_down event fired twice Pin
harold aptroot6-May-10 11:30
harold aptroot6-May-10 11:30 
GeneralRe: key_down event fired twice Pin
igalep1326-May-10 11:36
igalep1326-May-10 11:36 
AnswerRe: key_down event fired twice Pin
Luc Pattyn6-May-10 11:37
sitebuilderLuc Pattyn6-May-10 11:37 
GeneralRe: key_down event fired twice Pin
igalep1326-May-10 11:47
igalep1326-May-10 11:47 
GeneralRe: key_down event fired twice Pin
Luc Pattyn6-May-10 11:55
sitebuilderLuc Pattyn6-May-10 11:55 
GeneralRe: key_down event fired twice Pin
igalep1326-May-10 12:09
igalep1326-May-10 12:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.