Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suggestions For String and DateTime utility functions' Library using Extension Methods

I'm writing a library of Extension Methods for String and DateTime utility functions in C#. Can you please help me out by suggesting the useful utlity functions for String and DateTime you may want to be part of it ? With your suggestions I can make it more cohesive and Collective.

Thanks!

like image 277
this. __curious_geek Avatar asked Dec 02 '22 08:12

this. __curious_geek


1 Answers

public static bool IsNullOrEmpty(this string value){
    return string.IsNullOrEmpty(value);
}
public static string Reverse(this string value) {
    if (!string.IsNullOrEmpty(value)) {
        char[] chars = value.ToCharArray();
        Array.Reverse(chars);
        value = new string(chars);
    }
    return value;
}
public static string ToTitleCase(this string value) {
    return CultureInfo.CurrentCulture.TextInfo.ToTitleCase(value);
}
public static string ToTitleCaseInvariant(this string value) {
    return CultureInfo.InvariantCulture.TextInfo.ToTitleCase(value);
}

Trivial, but slighty nicer to call.

like image 148
Marc Gravell Avatar answered Dec 04 '22 22:12

Marc Gravell