Operations with Strings

Tango.CommonOperations.StringOperations

This static class contains methods and properties to expose common operations to work with string types.

All members bellow returns the corresponding functions as delegates.

Properties

Name Type Description
Concat Func<string, string> Function to represents concatenation operation string.Concat between two values.
Concat3 Func<string, string, string> Function to represents concatenation operation string.Concat between three values.

Methods

Name Parameters Returns Description
ConcatWith string value Func<string, string> Function to represents concatenation operation string.Concat between two values, applying first value as partial application on Concat function.
Concat3With string value Func<string, string, string> Function to represents concatenation operation string.Concat between three values, applying first value as partial application on Concat3 function.
Concat3With string value

string value2

Func<string, string> Function to represents concatenation operation string.Concat between three values, applying first and second values as partial application on Concat3 function.

Usage

The properties returns a delegate, so, it's possible to use it as a method.

Concat

string value = "Hello";
string value2 = " World";
string result = StringOperations.Concat(value, value2);

//result= "Hello World"

Concat3

string value = "Hello";
string value2 = " my ";
string value3 = "World";
string result = StringOperations.Concat3(value, value2, value3);

//result= "Hello my World"

Para os métodos temos uma sintaxe um pouco diferente, isso porque é realizada uma aplicação parcial ao método retornado pela própriedade.

Por conta disso, precisamos executar o método com os primeiros parâmetros, para obtermos um novo método que espera os parâmetros restantes:

ConcatWith

string value = "Hello";
string value2 = " World";
Func<string, string> concatWith = StringOperations.ConcatWith(value);
string result = concatWith(value2);

//result= "Hello World"

You can also use it as a chainable operation:

string value = "Hello";
string value2 = " World";
string result = StringOperations.ConcatWith(value)(value2);

//result= "Hello World"

The ~With operations are available to Concat3 as well, it follows the same caracteristics that the previous example.

Concat3With

string value = "Hello";
string value2 = " my ";
string value3 = "World";
Func<string, string, string> concat3With= StringOperations.Concat3With(value);
string result = concat3With(value2, value3);

//result= "Hello my World"

You can also use it as a chainable operation:

string value = "Hello";
string value2 = " my ";
string value3 = "World";
string result = StringOperations.Concat3With(value)(value2, value3);

//result= "Hello my World"

You can use the two parameters overload as well:

string value = "Hello";
string value2 = " my ";
string value3 = "World";
Func<string, string> concat3With= StringOperations.Concat3With(value, value2);
string result = concat3With(value3);

//result= "Hello my World"
string value = "Hello";
string value2 = " my ";
string value3 = "World";
string result = StringOperations.Concat3With(value, value2)(value3);

//result= "Hello my World"

results matching ""

    No results matching ""