2) Reverse a string
Write a function which accepts a string and returns a string with the words reversed. E,g “This is an example string” becomes “string example an is This”.many thanks

解决方案 »

  1.   

    easy job! Do it yourself!
      

  2.   

    Does the string contain any punctuations or only spaces besides characters?
      

  3.   

    using System;
    using System.Text;namespace RevString
    {

    class Class1
    {
    [STAThread]
    static void Main(string[] args)
    {
    StringBuilder org = new StringBuilder("This is an example string"); int length = org.Length; for(int i=0; i < length/2; i++)
    {
    char temp;
    temp = org[i];
    org[i]= org[length-i-1];
    org[length-i-1]= temp;
    } Console.WriteLine(org);
    }
    }
    }
      

  4.   

    Becoz I have no vss installed and Ihave to finished the technical test in a hurry.
    thank you all.
      

  5.   

    string sen = "This is an example string";
    string[] words = sen.Split(new char[]{' '});
    for (int i=words.Length-1; i>=0; i--)
    {
    Console.Write(words[i] + " ");
    }Result:
    string example an is This