//Microsoft Public License (Ms-PL)
//http://visualizer.codeplex.com/license
using System;
using System.Collections.Generic;
namespace Redwerb.BizArk.Core.StringExt
{
///
/// Provides extension methods for strings.
///
public static class StringExt
{
///
/// Gets the string up to the maximum number of characters.
///
///
///
///
public static string Max(this string str, int max)
{
return Max(str, max, false);
}
///
/// Gets the string up to the maximum number of characters. If ellipses is true and the string is longer than the max, the last 3 chars will be ellipses.
///
///
///
///
///
public static string Max(this string str, int max, bool ellipses)
{
if (str == null) return null;
if (str.Length <= max) return str;
if (ellipses)
return str.Substring(0, max - 3) + "...";
else
return str.Substring(0, max);
}
}
}