adding local varialbes - String?

  • Thread starter Thread starter Patrick Olurotimi Ige
  • Start date Start date
P

Patrick Olurotimi Ige

I have a DataTable:-
private void CreateForm(DataTable dt, string headerText)
{
}

string formTitle = tbxFormTitle.Text;
string formNotes = tbxFormnotes.Text;
DataTable dtForm = GetDataTable(formSql);

And i'm calling 2 local variable
dtForm,formTitle

Like so
CreateForm(dtForm,formTitle);
How can i add a 3rd one for example the string formNotes?
 
Either you can overload the CreateForm method to have one more parameter or
you can use string concatenation and add the thrid string with the second
string iteself seprated with and character(say #) and in the CreateForm
method you can again seprate back the two strings.

Hope this helps.
 
Sample for the override method:
private void CreateForm(DataTable dt, string headerText, string headerNotes)
{
}

and make a call like this:
CreateForm(dtForm,formTitle,formNotes);

Sample for string concatenation:

formTitle += "#" + formNotes;
call in the same way as you are doing
CreateForm(dtForm,formTitle)

and in the method do this way:

private void CreateForm(DataTable dt, string headerText)
{
string formNotes = "';
//some verification here like whether there is any text after the # in the
headerText variable

if(headerText.Length > headerText.IndexOf("#") + 1)
formNotes = headerText.Substring(headerText.IndexOf("#")+1);

//do the normal processing here
}
 
Back
Top