中国移动服务网号 "134", "135", "136", "137","138", "139", "147","150", "151", "152", "157", "158", "159", "182","183","184", "187", "188", "178"
中国联通服务网号 "130", "131", "132", "145","155", "156","186", "185","176"
中国电信服务网号 "133", "153", "180", "181", "189" ''177'
170虚拟运营商专属号段,电信是1700;联通是1709;移动是1705
/// <summary>/// 获取判断手机运营商/// </summary>/// <param name="mobile"></param>/// <returns></returns>public static string validateMobile(string mobile){String returnString = "";if (mobile == null || mobile.Trim().Length != 11){return "-1"; //mobile参数为空或者手机号码长度不为11,错误! }if (mobile.Trim().Substring(0, 3).Equals("134") || mobile.Trim().Substring(0, 3).Equals("135") ||mobile.Trim().Substring(0, 3).Equals("136") || mobile.Trim().Substring(0, 3).Equals("137")|| mobile.Trim().Substring(0, 3).Equals("138") || mobile.Trim().Substring(0, 3).Equals("139") || mobile.Trim().Substring(0, 3).Equals("150") ||mobile.Trim().Substring(0, 3).Equals("151") || mobile.Trim().Substring(0, 3).Equals("152")|| mobile.Trim().Substring(0, 3).Equals("157") || mobile.Trim().Substring(0, 3).Equals("158") || mobile.Trim().Substring(0, 3).Equals("159") || mobile.Trim().Substring(0, 3).Equals("182") || mobile.Trim().Substring(0, 3).Equals("183") || mobile.Trim().Substring(0, 3).Equals("187") || mobile.Trim().Substring(0, 3).Equals("188") || mobile.Trim().Substring(0, 3).Equals("147")){returnString = "1"; //中国移动 }if (mobile.Trim().Substring(0, 3).Equals("130") || mobile.Trim().Substring(0, 3).Equals("131") ||mobile.Trim().Substring(0, 3).Equals("132") || mobile.Trim().Substring(0, 3).Equals("145") || mobile.Trim().Substring(0, 3).Equals("155") || mobile.Trim().Substring(0, 3).Equals("156") || mobile.Trim().Substring(0, 3).Equals("185") ||mobile.Trim().Substring(0, 3).Equals("186")){returnString = "2"; //中国联通 }if (mobile.Trim().Substring(0, 3).Equals("133") || mobile.Trim().Substring(0, 3).Equals("153") ||mobile.Trim().Substring(0, 3).Equals("180") || mobile.Trim().Substring(0, 3).Equals("181") || mobile.Trim().Substring(0, 3).Equals("189")){returnString = "3"; //中国电信 }if (returnString.Trim().Equals("")){returnString = "0"; //未知运营商 }return returnString;}
第二种比较全面效果极佳方式:#region 判断三大运营商 移动、联通、电信/// <summary>/// 判断三大运营商 移动、联通、电信/// </summary>/// <param name="mobile"></param>/// <returns></returns>public string GetMobileType(string mobile){ string result = "";try{if (mobile == null || mobile.Trim().Length != 11){return "-1"; //mobile参数为空或者手机号码长度不为11,错误! }if (mobile.StartsWith("0") || mobile.StartsWith("+860")){mobile = mobile.Substring(mobile.IndexOf("0") + 1, mobile.Length);}//中国移动服务网号 4G号段 178ArrayList ChinaMobile = ArrayList.Adapter(new string[] {"134", "135", "136", "137", "138", "139", "147","150", "151", "152", "157", "158", "159", "182","183","184", "187", "188", "178" });//中国联通服务网号 4G号段 176ArrayList ChinaUnicom = ArrayList.Adapter(new string[] { "130", "131", "132", "145","155", "156","186", "185","176" });//中国电信服务网号 177属于4G号段 ArrayList ChinaTelecom = ArrayList.Adapter(new string[] { "133", "153", "180", "181", "189", "177" });bool bolChinaMobile = (ChinaMobile.Contains(mobile.Substring(0, 3)));bool bolChinaUnicom = (ChinaUnicom.Contains(mobile.Substring(0, 3)));bool bolChinaTelecom = (ChinaTelecom.Contains(mobile.Substring(0, 3)));//if (bolChinaMobile)// return result = "1"; // 移动 //if (bolChinaUnicom)// return result = "2"; // 联通 //if (bolChinaTelecom)// return result = "3"; // 电信//170虚拟运营商专属号段,电信是1700;联通是1709;移动是1705。if (bolChinaMobile || mobile.Substring(0, 4) == "1705")return result = "1"; // 移动 if (bolChinaUnicom || mobile.Substring(0, 4) == "1709")return result = "2"; // 联通 if (bolChinaTelecom || mobile.Substring(0, 4) == "1700")return result = "3"; // 电信 if (result.Trim().Equals("")){result = "0"; //未知运营商 }}catch { }return result;}#endregion