/// 호출형태 addHyphen(phone.Replace("-", "");
public string addHyphen(string tel)
{
string t1 = string.Empty, t2 = string.Empty, t3 = string.Empty, t_sum = string.Empty;
if (tel.Length == 8) //1588-xxxx
{
t1 = tel.Substring(0, 4);
t2 = tel.Substring(4, 4);
t_sum = t1 + "-" + t2;
}
else if (tel.Length == 9) //02-xxx-xxxx
{
t1 = tel.Substring(0, 2);
t2 = tel.Substring(2, 3);
t3 = tel.Substring(5, 4);
t_sum = t1 + "-" + t2 + "-" + t3;
}
else if (tel.Length == 10)
{
if (tel.Substring(0, 2) == "01") //휴대전화 010-xxx-xxxx
{
t1 = tel.Substring(0, 3);
t2 = tel.Substring(3, 3);
t3 = tel.Substring(6, 4);
t_sum = t1 + "-" + t2 + "-" + t3;
}
else if (tel.Substring(0, 2) == "02")
{
t1 = tel.Substring(0, 2);
t2 = tel.Substring(2, 4);
t3 = tel.Substring(6, 4);
t_sum = t1 + "-" + t2 + "-" + t3;
}
else
{
t1 = tel.Substring(0, 3);
t2 = tel.Substring(3, 3);
t3 = tel.Substring(6, 4);
t_sum = t1 + "-" + t2 + "-" + t3;
}
}
else if (tel.Length == 11) //xxx-xxxx-xxxx(휴대전화,070)
{
t1 = tel.Substring(0, 3);
t2 = tel.Substring(3, 4);
t3 = tel.Substring(7, 4);
t_sum = t1 + "-" + t2 + "-" + t3;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////