Strings Manipulation
public static void Main( string[] args )
{
Console.WriteLine( "string1 = " + "\"" + string1 + "\"\n" +
"string2 = " + "\"" + string2 + "\"\n" +
"string3 = " + "\"" + string3 + "\"\n" +
"string4 = " + "\"" + string4 + "\"\n" );
} // end Main
// end class StringConstructor
// string initialization
char[] characterArray =
{ 'b', 'i', 'r', 't', 'h', ' ', 'd', 'a', 'y' };
string originalString = "Welcome to C# programming!";
string string1 = originalString;
string string2 = new string( characterArray );
string string3 = new string( characterArray, 6, 3 );
string string4 = new string( 'C', 5 );
}
output
string1 = "Welcome to C# programming!"
string2 = "birth day"
string3 = "day"
string4 = "CCCCC"
No comments:
Post a Comment