using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace StringManipulationPost
{
class Program
{
static void Main(string[] args)
{
string string1 = "hello";
string string2 = "good bye";
string string3 = "Happy Birthday";
string string4 = "happy birthday";
Console.WriteLine( "string1 = \"" + string1 + "\"" +
"\nstring2 = \"" + string2 + "\"" +
"\nstring3 = \"" + string3 + "\"" +
"\nstring4 = \"" + string4 + "\"\n" );
// test for equality using Equals method
if ( string1.Equals( "hello" ) )
Console.WriteLine( "string1 equals \"hello\"" );
else
Console.WriteLine( "string1 does not equal \"hello\"" );
// test for equality with ==
if ( string1 == "hello" )
Console.WriteLine( "string1 equals \"hello\"" );
else
Console.WriteLine( "string1 does not equal \"hello\"" );
// test for equality comparing case
if ( string.Equals( string3, string4 ) ) // static method
Console.WriteLine( "string3 equals string4" );
else
Console.WriteLine( "string3 does not equal string4" );
string1.Equals( "hello" );
//string1 == "hello";
string.Equals( string3, string4 );
Console.ReadLine();
}
}
}
No comments:
Post a Comment