C# 手机号中间四位星号显示

C# 手机号中间四位星号显示
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApp22
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("手机号中间四位星号显示: {0}", HideMobile("13312341234"));
            Console.Read();
        }

        /// <summary>
        /// 隐藏手机号中间4位
        /// </summary>
        /// <param name="mobile"></param>
        /// <returns></returns>
        public static string HideMobile(string mobile)
        {
            if (mobile.Length == 11)
            {
                return mobile.Substring(0, 3) + "****" + mobile.Substring(7);
            }
            else
            {
                return mobile;
            }
        }
    }
}


热门推荐