Quantcast Phân biệt HOA thường với StringComparer.OrdinalIgnoreCase

Phân biệt HOA thường với StringComparer.OrdinalIgnoreCase

by Neon Quach 1. April 2010 03:24

 

using System;

using System.Linq;

 

namespace CS

{

    class Program

    {

        static void Main(string[] args)

        {

            string[] name = { "NeonQuach", "QuachNguyen" };

            if (name.Contains("neonquach",StringComparer.OrdinalIgnoreCase))

            {

                Console.WriteLine("compare with no case-sensitive, neonquach exits in name array");

            }

            else if (name.Contains("neonquach"))

            {

                Console.WriteLine("compare with case-sensitive");

            }

            Console.Read();

        }

    }

}


VB.NET
Module Module1

 

    Sub Main()

        Dim name As String() = {"NeonQuach", "QuachNguyen"}

        If name.Contains("neonquach", StringComparer.OrdinalIgnoreCase) Then

            Console.WriteLine("compare with no case-sensitive, neonquach exits in name array")

        ElseIf name.Contains("neonquach") Then

            Console.WriteLine("compare with case-sensitive")

        End If

        Console.Read()

    End Sub

 

End Module


Mặc định nếu không có StringComparer.OrdinalIgnoreCase thì chuổi chúng ta đem đi so sánh nó phân biệt Hoa thường

http://code2code.googlecode.com/svn/trunk/StringComparerOrdinalIgnoreCase

Tags: , ,


Categories: net framework | c# | vb.net

blog comments powered by Disqus

About me

I'm  currently employed as Software developer at devinition.com and also a Microsoft Certified Technology Specialist (MCTS), Microsoft Certified Professional Developer (MCPD) in Net Framework 2.0 and 3.5: Web Applications and MCTS .NET Framework 3.5, ADO.NET Applications

Powered by BlogEngine.NET 2.5.0.5 - Eco Theme by n3o Web Designers