StringExtensions ClassDelta Engine Documentation
Provides additional and simplified string manipulation methods. View code on GitHub
Inheritance Hierarchy

System Object
  DeltaEngine.Extensions StringExtensions

Namespace: DeltaEngine.Extensions
Assembly: DeltaEngine (in DeltaEngine.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public static class StringExtensions

The StringExtensions type exposes the following members.

Methods

  NameDescription
Public methodStatic memberAddConvertTypeCreation
Public methodStatic memberCompare
Public methodStatic memberContainsCaseInsensitive
Public methodStatic memberConvert T 
Public methodStatic memberConvertFirstCharacterToUpperCase
Public methodStatic memberFromByteArray
Public methodStatic memberGetFilenameWithoutForbiddenCharactersOrSpaces
Public methodStatic memberIsFirstCharacterInLowerCase
Public methodStatic memberMaxStringLength
Public methodStatic memberSplitAndTrim(String,  Char )
Public methodStatic memberSplitAndTrim(String,  String )
Public methodStatic memberSplitIntoFloats(String)
Public methodStatic memberSplitIntoFloats( String )
Public methodStatic memberSplitIntoFloats(String,  Char )
Public methodStatic memberSplitIntoFloats(String,  String )
Public methodStatic memberSplitWords
Public methodStatic memberStartsWith
Public methodStatic memberToByteArray
Public methodStatic memberToInvariantString(Object)
Public methodStatic memberToInvariantString(Single)
Public methodStatic memberToInvariantString(Single, String)
Top
Remarks

Tests: DeltaEngine.Tests.Extensions.StringExtensionsTests
Examples

21 unit tests call DeltaEngine.Extensions.StringExtensions
[Test]
public void ConvertFloatToInvariantString()
{
    Assert.AreEqual("2.5", 2.5f.ToInvariantString());
    Assert.AreNotEqual("3.5", 1.5f.ToInvariantString());
    Assert.AreEqual("01", 1.0f.ToInvariantString("00"));
    Assert.AreEqual("1.23", 1.2345f.ToInvariantString("0.00"));
    Assert.AreNotEqual("1.2345", 1.2345f.ToInvariantString("0.00"));
    Assert.AreEqual("1", StringExtensions.ToInvariantString(1));
}
[Test]
public void Convert()
{
    Assert.AreEqual(1.0f, "1.0".Convert<float>());
    Assert.AreEqual("abc", "abc".Convert<string>());
    Assert.Throws<FormatException>(() => "val".Convert<float>());
    Assert.AreEqual(1, "1".Convert<int>());
    Assert.AreEqual(24, "24".Convert<int>());
    Assert.AreEqual('A', "A".Convert<char>());
    Assert.AreEqual(943578.39543, "943578.39543".Convert<double>());
    Assert.AreEqual(true, "True".Convert<bool>());
    Assert.AreEqual(false, "False".Convert<bool>());
    Assert.AreEqual(SomeEnum.Additive, "Additive".Convert<SomeEnum>());
    Assert.AreEqual(new DateTime(2002, 12, 24), "2002-12-24".Convert<DateTime>());
}
[Test]
public void ToInvariantString()
{
    Assert.AreEqual("null", StringExtensions.ToInvariantString(null));
    Assert.AreEqual("1", StringExtensions.ToInvariantString((object)1.0f));
    Assert.AreEqual("1.2", StringExtensions.ToInvariantString(1.2));
    Assert.AreEqual("1.4", StringExtensions.ToInvariantString(1.4m));
    Assert.AreEqual("abc", StringExtensions.ToInvariantString("abc"));
    Assert.AreEqual("01/01/2014 00:00:00",
        StringExtensions.ToInvariantString(new DateTime(2014, 1, 1)));
}
See Also