CSharp examples for System:String SubString
Return the substring after but not including the last instance of 'c'.
using System;/* ww w .j av a 2 s.com*/ public class Main{ /// <summary> /// Return the substring after but not including the last instance of 'c'. /// </summary> /// <param name="src">The source string.</param> /// <param name="c">The character to look for.</param> /// <returns>The substring after but not including the last instance of 'c'. If 'c' is not found, the entire string is returned.</returns> public static string SubstringAfterLast (this String src, char c) { if (String.IsNullOrEmpty(src)) return ""; int idx = Math.Min(src.Length - 1, src.LastIndexOf(c) + 1); if (idx < 0) return src; return src.Substring(idx); } }