Monthly Archives: September 2011

Mask Mobile Number Using C#

A small piece of code which mask any string with specific mask characters. // Mask the mobile. // Usage: MaskMobile("13456789876", 3, "****") => "134****9876" public static string MaskMobile(string mobile, int startIndex, string mask) { if (string.IsNullOrEmpty(mobile)) return string.Empty; string result = mobile; int starLengh = mask.Length; if (mobile.Length >= startIndex) { result = mobile.Insert(startIndex, mask);… Read More »

Category: c#