多个手机号逗号分开
时间:2014-05-25 23:48:39
收藏:0
阅读:459
#region 测试 数组类型的 string[] mobiles = new string[] { "18975887650", "18775887650", "18977487650", "18975887512" }; /// <summary> /// 循环获取多个手机号逗号分开 /// </summary> /// <returns></returns> public string GetMobile() { string strmobile = ""; for (int i = 0; i < mobiles.Length; i++) { strmobile += mobiles[i] + ","; } if (strmobile.Length > 0) { strmobile = strmobile.Substring(0, strmobile.Length - 1); return strmobile; } return strmobile; } #endregion
数据库中获取:
#region 多个手机号 /// <summary> /// 获取用户电话号码 数据库中获取 数组中多个手机号逗号分开 /// </summary> public string GetMobileNumber() { string strmobilenumbers = ""; DataTable dt = jub.Get_Mobile(mu.MobileNumber); //从数据库中读取手机信息数据 // mobiles = dt.Rows[0]["MobileNumber"].ToString(); //定义数组 string[] mobilenumbers = new string[dt.Rows.Count]; if (dt.Rows.Count > 0) { //循环数据 for (int i = 0; i < dt.Rows.Count; i++) { DataRow dr = dt.Rows[i]; mobilenumbers[i] = dr["MobileNumber"].ToString();//为数组赋值 strmobilenumbers += mobilenumbers[i] + ","; } if (strmobilenumbers.Length > 0) { strmobilenumbers = strmobilenumbers.Substring(0, strmobilenumbers.Length - 1); return strmobilenumbers; } return strmobilenumbers; } return strmobilenumbers; } #endregion
评论(0)