top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

c# function that returns string

0 votes

haw can i send string to function,do something with it and return to main in C#

posted Apr 28, 2017 by Leon Martinović

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

You can pass a string to function from main as given below:

I am passing string "MyName" to DisplayMessage function.The DisplayMessage function will return me another string which I will receive in displayName variable and can print it.

  string name="MyName";
   string displayName=DisplayMessage(name);

public void DisplayMessage(string name)
 return "Leon";
answer May 3, 2017 by Shweta Singh
Similar Questions
0 votes

#region shell_sort

          //element for one step of sort
          int elm = 3;

          for (int i = 0; i != niz_brojeva.Length; i++)
              int j = i + elm;

              if (j >= niz_brojeva.Length)
              { j = Convert.ToInt32(niz_brojeva.Length - 1); }

              while (i != j)

                  if (niz_brojeva[i] > niz_brojeva[j])
                      int temp;
                      temp = niz_brojeva[i];
                      niz_brojeva[i] = niz_brojeva[j];
                      niz_brojeva[j] = temp;          
                  } j--; }
Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.