adding local varialbes - String?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Patrick Olurotimi Ige

    adding local varialbes - String?

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

    string formTitle = tbxFormTitle.Te xt;
    string formNotes = tbxFormnotes.Te xt;
    DataTable dtForm = GetDataTable(fo rmSql);

    And i'm calling 2 local variable
    dtForm,formTitl e

    Like so
    CreateForm(dtFo rm,formTitle);
    How can i add a 3rd one for example the string formNotes?


    *** Sent via Developersdex http://www.developersdex.com ***
  • Hitesh

    #2
    RE: adding local varialbes - String?

    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.

    "Patrick Olurotimi Ige" wrote:
    [color=blue]
    > I have a DataTable:-
    > private void CreateForm(Data Table dt, string headerText)
    > {
    > }
    >
    > string formTitle = tbxFormTitle.Te xt;
    > string formNotes = tbxFormnotes.Te xt;
    > DataTable dtForm = GetDataTable(fo rmSql);
    >
    > And i'm calling 2 local variable
    > dtForm,formTitl e
    >
    > Like so
    > CreateForm(dtFo rm,formTitle);
    > How can i add a 3rd one for example the string formNotes?
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    >[/color]

    Comment

    • Patrick Olurotimi Ige

      #3
      RE: adding local varialbes - String?

      Hitesh..
      Can you post me a sample!



      *** Sent via Developersdex http://www.developersdex.com ***

      Comment

      • Hitesh

        #4
        RE: adding local varialbes - String?

        Sample for the override method:
        private void CreateForm(Data Table dt, string headerText, string headerNotes)
        {
        }

        and make a call like this:
        CreateForm(dtFo rm,formTitle,fo rmNotes);

        Sample for string concatenation:

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

        and in the method do this way:

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

        if(headerText.L ength > headerText.Inde xOf("#") + 1)
        formNotes = headerText.Subs tring(headerTex t.IndexOf("#")+ 1);

        //do the normal processing here
        }




        "Patrick Olurotimi Ige" wrote:
        [color=blue]
        > Hitesh..
        > Can you post me a sample!
        >
        >
        >
        > *** Sent via Developersdex http://www.developersdex.com ***
        >[/color]

        Comment

        Working...