Saturday, August 7, 2010

Program using string builder class


Write a program using string builder class.
public void strignbuilder()
        {
            StringBuilder sb = new StringBuilder("Hi there.");
            Console.WriteLine("{0}", sb);
            sb.Replace("Hi", "Hello");
            Console.WriteLine("{0}", sb);
    public void reverse()
        {
            string[] s = new string[3];
            s[0] = "Number1";
            s[1] = "Number2";
            s[2] = "Number3";
            Console.WriteLine("The elements in string are");
            foreach (string c in s)
            {
                Console.WriteLine("{0}", c);
            }
            List<string> rever = new List<string>();
            rever = s.Reverse<string>().ToList<string>();
            Console.WriteLine("The elements of string in reverse order are");
            foreach (string c in rever)
            {
                Console.WriteLine("{0}:", c);
            }
        }   

No comments:

Post a Comment