String Compare in C#

on

The “System.IO” namespace contains types that allow reading and writing to files and data streams, and types that provide basic file and directory support.

The “System” namespace contains fundamental classes and base classes that define commonly-used value and reference data types, events and event handlers, interfaces, attributes, and processing exceptions.

The “System.Text” namespace contains classes that represent ASCII and Unicode character encodings; abstract base classes for converting blocks of characters to and from blocks of bytes; and a helper class that manipulates and formats String objects without creating intermediate instances of String.

 using System.IO;
 using System;
 using System.Text;

 class Program
 {
    static void Main()
    {
        // Avoid getting confused by interning
        object x = new StringBuilder("hello").ToString();
        object y = new StringBuilder("hello").ToString();
        bool success = false;
        if (x.Equals(y)){
             success = true;
        } // Yes
        Console.WriteLine(success); 
    }
 }

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s