diff --git a/src/Z.Core/System.String/String.EqualsIgnoreCase.cs b/src/Z.Core/System.String/String.EqualsIgnoreCase.cs new file mode 100644 index 00000000..f9ada8e6 --- /dev/null +++ b/src/Z.Core/System.String/String.EqualsIgnoreCase.cs @@ -0,0 +1,23 @@ +// Description: C# Extension Methods Library to enhances the .NET Framework by adding hundreds of new methods. It drastically increases developers productivity and code readability. Support C# and VB.NET +// Website & Documentation: https://github.com/zzzprojects/Z.ExtensionMethods +// Forum: https://github.com/zzzprojects/Z.ExtensionMethods/issues +// License: https://github.com/zzzprojects/Z.ExtensionMethods/blob/master/LICENSE +// More projects: http://www.zzzprojects.com/ +// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved. +using System; + +public static partial class Extensions +{ + /// + /// A string extension method that checks if '@this' is equal to another string regardless of it's case. + /// + /// The @this to act on. + /// The compared string. + /// + /// true if it contains all values, otherwise false. + /// + public static bool EqualsIgnoreCase(this string @this, string comparedString) + { + return @this.Equals(comparedString, StringComparison.OrdinalIgnoreCase); + } +} \ No newline at end of file diff --git a/src/Z.Core/Z.Core.csproj b/src/Z.Core/Z.Core.csproj index a83b04d9..84c5b4dd 100644 --- a/src/Z.Core/Z.Core.csproj +++ b/src/Z.Core/Z.Core.csproj @@ -508,6 +508,7 @@ + diff --git a/test/Z.Core.Test/System.String/String.EqualsIgnoreCase.cs b/test/Z.Core.Test/System.String/String.EqualsIgnoreCase.cs new file mode 100644 index 00000000..f1babd86 --- /dev/null +++ b/test/Z.Core.Test/System.String/String.EqualsIgnoreCase.cs @@ -0,0 +1,29 @@ +// Description: C# Extension Methods Library to enhances the .NET Framework by adding hundreds of new methods. It drastically increases developers productivity and code readability. Support C# and VB.NET +// Website & Documentation: https://github.com/zzzprojects/Z.ExtensionMethods +// Forum: https://github.com/zzzprojects/Z.ExtensionMethods/issues +// License: https://github.com/zzzprojects/Z.ExtensionMethods/blob/master/LICENSE +// More projects: http://www.zzzprojects.com/ +// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved. +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Core.Test +{ + [TestClass] + public class System_String_EqualsIgnoreCase + { + [TestMethod] + public void EqualsIgnoreCase() + { + // Type + string @this = "FizBuzz"; + + // Examples + bool value1 = @this.EqualsIgnoreCase("fizbuzz"); // return true; + bool value2 = @this.EqualsIgnoreCase("FooBar"); // return false; + + // Unit Test + Assert.IsTrue(value1); + Assert.IsFalse(value2); + } + } +} \ No newline at end of file diff --git a/test/Z.Core.Test/Z.Core.Test.csproj b/test/Z.Core.Test/Z.Core.Test.csproj index db9cc519..be0eabfe 100644 --- a/test/Z.Core.Test/Z.Core.Test.csproj +++ b/test/Z.Core.Test/Z.Core.Test.csproj @@ -62,6 +62,7 @@ +