using System;
class StringMethods
{
public 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( );
// copy characters from string1 into characterArray
Console.Write( "\nThe character array is: " );
for ( int i = 0; i < ; i++ )
Console.Write( );
Console.WriteLine( "\n" );
} // end Main
} // end class StringMethods
// test Length property
Console.WriteLine( "Length of string1: " + string1.Length );
string1.Length
string1[ i ]
string1.CopyTo( 0, characterArray, 0, characterArray.Length );
characterArray.Length
characterArray[ i ]
ouput
string1: "hello there"
Length of string1: 11
The string reversed is: ereht olleh
The character array is: hello
No comments:
Post a Comment