Tuesday 13 November 2012

c sharp programming

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace StringManipulationPost
{
    class Program
    {
        static void Main(string[] args)
        {
          
           string string1 = "hello there";
        char[] characterArray = new char[ 5 ];
// output string1
        Console.WriteLine( "string1: \"" + string1 + "\"" );
// loop through characters in string1 and display reversed
      Console.Write( "The string reversed is: " );
      for ( int i =   - 1; i >= 0; i-- )
      Console.Write( string1[i]  );
// copy characters from string1 into characterArray 
             string1.CopyTo( 0, characterArray, 0, characterArray.Length );
      Console.Write( "\nThe character array is: " );
     for ( int i = 0; i < characterArray.Length  ; i++ )
      Console.Write(characterArray[i]);
 
      Console.WriteLine( "\n" );

// test Length property                                    
       Console.WriteLine( "Length of string1: " + string1.Length );

       Console.ReadLine();
 
        }
    }
}

No comments:

Post a Comment