Description |
Returns true if the two strings have exactly the same value. It is case sensitive.
Strings are objects in .Net (even though they are not implicitly created). Flavours 1 and 2 of the Equals method are methods of a string object.
Flavours 3 and 4 are static methods of the String class - meaning that you run the method standalone rather than against a string object. In this case, the two strings (or string objects) are passed as parameters.
|
|
Microsoft MSDN Links |
system
system.String
|
|
|
Comparing one string with another |
program Project1;
{$APPTYPE CONSOLE}
var
a, b : String;
begin
a := '12345';
b := '123';
if a.Equals(b)
then Console.WriteLine('Match')
else Console.WriteLine('No match');
b := b + '45';
if a.Equals(b)
then Console.WriteLine('Match')
else Console.WriteLine('No match');
Console.ReadLine;
end.
| Show full unit code | No match
Match
| | Comparing two strings using the static Equals method | program Project1;
{$APPTYPE CONSOLE}
var
a, b : String;
begin
a := '12345';
b := '123';
if System.String.Equals(a, b)
then Console.WriteLine('Match')
else Console.WriteLine('No match');
b := b + '45';
if System.String.Equals(a, b)
then Console.WriteLine('Match')
else Console.WriteLine('No match');
Console.ReadLine;
end.
| Show full unit code | No match
Match
|
|
|
|