CSharp examples for System:String Shorten
Shorten String For Title
using System.Xml.Linq; using System.Web; using System.Text.RegularExpressions; using System.Text; using System.Linq; using System.Collections.Generic; using System;/*from w ww . j a va2 s. c om*/ public class Main{ public static string ShortenStringForTitle(string one, string two, string three) { var result = string.Empty; var fullResult = string.Empty; if (!String.IsNullOrEmpty(one)) { if (one.Length >= 30) { result = one.Substring(0, 30) + "..."; } else { result = one; } fullResult = one; } else if (!String.IsNullOrEmpty(two)) { if (two.Length >= 30) { result = two.Substring(0, 30) + "..."; } else { result = two; } fullResult = two; } else if (!String.IsNullOrEmpty(three)) { if (three.Length >= 30) { result = three.Substring(0, 30) + "..."; } else { result = three; } fullResult = three; } return fullResult; } }