|
namespace ExtensionExampleApp.Utility
{
public static class Extensions
{
/// <summary>
/// Checks if string is null, empty or consists only of spaces (in which case returns false)
/// </summary>
/// <param name="value"></param>
/// <returns>true if string is none of the above</returns>
public static bool HasValue(this string text)
{
return (text != null && text.Trim() != string.Empty);
}
public static string AddExclamationMark(this string text)
{
return text + "!";
}
public static string AddAditionalText(this string text, string add)
{
return text + add;
}
}
public static class StringHelper
{
//static method for C# 2.0
//identical to Exentensions.HasValue except for the keyword 'this'
public static bool HasValue(string text)
{
return (text != null && text.Trim() != string.Empty);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.