ASP.NET 字符串去重
来源:互联网 发布:出知西安之咸宁翻译 编辑:程序博客网 时间:2024/06/12 22:07
string strPlanReceiver = string.Empty; string strPlanReceiveRole = string.Empty; TaskModel model = new TaskModel(); SystemManager syMan = new SystemManager(); model = syMan.GetTaskReceiverInfoByID(TaskID); //根据TaskID获取任务接收人配置信息 if (model != null) { #region 构造接收人、接收人角色字符串,并去重 //构造接收人、接收人角色字符串,用于发送消息 strPlanReceiver += model.PlanReceiver + ","; strPlanReceiver += model.PlanReceiver0 + ","; strPlanReceiver += model.PlanReceiver1 + ","; strPlanReceiver += model.PlanReceiver2 + ","; strPlanReceiver += model.PlanReceiver3 + ","; strPlanReceiver = strPlanReceiver.Trim(','); strPlanReceiveRole += model.PlanReceiveRole + ","; strPlanReceiveRole += model.PlanReceiveRole0 + ","; strPlanReceiveRole += model.PlanReceiveRole1 + ","; strPlanReceiveRole += model.PlanReceiveRole2 + ","; strPlanReceiveRole += model.PlanReceiveRole3 + ","; strPlanReceiveRole = strPlanReceiveRole.Trim(','); //字符串去重 strPlanReceiver = StringUnique(strPlanReceiver); //接收人字符串去重 strPlanReceiveRole = StringUnique(strPlanReceiveRole); //接收角色字符串去重 #endregion }
#region 字符串去重 /// <summary> /// 字符串去重 /// </summary> /// <param name="strList"></param> /// <returns></returns> private string StringUnique(string strList) { //1.把字符串转换成数组 string result = string.Empty; string[] str_num = strList.Split(','); //2.定义ArrayList,判断数组中重复字段不添加到 ArrayList对象中 ArrayList al = new ArrayList(); for (int i = 0; i < str_num.Length; i++) { //判断是否已经存在 if (al.Contains(str_num[i]) == false) { al.Add(str_num[i]); } } //3.将arrayList转换成数组 str_num = new String[al.Count]; str_num = (string[])al.ToArray(typeof(string)); //3.数组转字符串,并以逗号间隔 result = string.Join(",", str_num); return result; ; } #endregion
阅读全文
0 0
- ASP.NET 字符串去重
- C# asp.net中字符串数组去重
- ASP.NET Lambda去重方法
- 字符串去重
- 字符串去重
- java 字符串去重
- js 字符串去重
- 字符串去重/C#
- 数字、字符串去重
- 字符串去重
- TreeSet去重字符串
- 字符串去重
- 字符串数组去重
- Java字符串去重
- 字符串数组去重
- 字符串去重
- js字符串去重
- 字符串去重 java
- HDU6098 Inversion(RMQ,2017 HDU多校联赛 第6场)
- c++基础入门
- Netty心跳机制
- 彻底根除“无法安装64位版本的Office,因为在您的PC上找到了以下32位程序:”的问题
- bzoj 3745: [Coci2015]Norma
- ASP.NET 字符串去重
- PHP7新特性 What will be in PHP 7/PHPNG
- linux C++ regex性能比较
- STM32F103: NRF24L01
- STM32F407: USART 遇到的问题
- 小练习:计算汉明距离
- CUDA初试
- Android Studio中 GreenDao 基本配置
- python:webbrowser