C#利用 string.Join 泛型集合快速转换拼接字符串
C#利用 string.Join 泛型集合快速转换拼接字符串
List<int> superior_list = new List<int>();
superior_list.Add("1");
superior_list.Add("2");
superior_list.Add("3");
superior_list.Add("4");
if (superior_list.Count > 0)
{
_superior = string.Join(",", superior_list.ToArray());
}
可以根据实际业务需要封装获取对应方法
public string get_superior(string superior_id)
{
string _superior = string.Empty;
List<int> superior_list = new List<int>();
List<YY.Model.A_AdminUser> list = new YY.BLL.A_AdminUser().GetList(null, "JobCode='" + (int)Enums.JobType.工程师 + "' and Superior<>''", null);
if (list.Count > 0)
{
foreach (YY.Model.A_AdminUser AdminUserModel in list)
if (AdminUserModel.Superior.Length > 0)
{
string[] arr = AdminUserModel.Superior.Split('|');
for (int i = 0; i < arr.Length; i++)
{
if (superior_id == arr[i])
{
superior_list.Add(AdminUserModel.id);
continue;
}
}
}
}
if (superior_list.Count > 0)
{
_superior = string.Join(",", superior_list.ToArray());
}
return _superior;
}
C#利用 string.Join 泛型集合快速转换拼接字符串的更多相关文章
- Reflection和Expression Tree解析泛型集合快速定制特殊格式的Json
很多项目都会用到Json,而且大部分的Json都是格式固定,功能强大,转换简单等,标准的key,value集合字符串:直接JsonConvert.SerializeObject(List<T&g ...
- js join()函数将数组转换成字符串
join() 方法用于把数组中的所有元素放入一个字符串.作用是将数组转换为字符串,其作用和toString()相同. 元素是通过指定的分隔符进行分隔的. 例如: var asp=['H','ell', ...
- 【学习笔记】C#中的泛型和泛型集合
一.什么是泛型? 泛型是C#语言和公共语言运行库(CLR)中的一个新功能,它将类型参数的概念引入.NET Framework.类型参数使得设计某些类和方法成为可能,例如,通过使用泛型类型参数T,可以大 ...
- 利用反射将Datatable、SqlDataReader转换成List模型
1. DataTable转IList public class DataTableToList<T>whereT :new() { ///<summary> ///利用反射将D ...
- 02.List泛型集合
List泛型可以转换成数组 List泛型和数组的相同点: List泛型的数据类型必须是指定的,数组的数据类型也必须是指定的. List泛型和数组的不同点: List泛型的长度是随意的,而数组的长度必须 ...
- C#面向对象14 List泛型集合/装箱和拆箱/字典集合(Dictionary)
1.List泛型集合 using System; using System.Collections.Generic; using System.Linq; using System.Text; usi ...
- C#基础精华03(常用类库StringBuilder,List<T>泛型集合,Dictionary<K , V> 键值对集合,装箱拆箱)
常用类库StringBuilder StringBuilder高效的字符串操作 当大量进行字符串操作的时候,比如,很多次的字符串的拼接操作. String 对象是不可变的. 每次使用 System. ...
- 泛型集合List(C#)
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace List ...
- C# string.join
String.Join 方法 平常工作中经常用到string.join()方法,在vs 2017用的运行时(System.Runtime, Version=4.2.0.0)中,共有九个(重载)方法. ...
随机推荐
- Apache Hadoop配置Kerberos指南
通常,一个Hadoop集群的安全使用kerberos来进行保障.在启用Kerberos后,需要用户进行身份验证.用户通过验证后可以使用GRANT/REVOKE语句来进行基于角色的访问控制.本文介绍一下 ...
- PHP码农在Golang压力下的生存之道-PHP性能优化实践
随着国内Golang的火爆,phper的生存压力越来越大,在一次内部技术讨论中,gopher甚至提出,要什么php,写php的全部开掉,唉,码农何苦为难码农. 本文试图寻找一种有效实践,减少php w ...
- [Python Study Notes] python面试题总结
python语法以及其他基础部分 可变与不可变类型: 浅拷贝与深拷贝的实现方式.区别:deepcopy如果你来设计,如何实现: __new__() 与 __init__()的区别: 你知道几种设计模式 ...
- yii2 源码分析 Component类分析 (二)
转载请注明链接http://www.cnblogs.com/liuwanqiu/p/6739538.html 组件(component),是Yii框架的基类,实现了属性.事件.行为三类功能,它集成自o ...
- 浅讲JUnit
JUnit单元简介: JUnit ----是一个开发源码的java测试框架,用于编写和运行可重复的测试,它是用于单元测试框架体系xUnit的一个实例, 用于java语言,主要用于白盒测试,回 ...
- 集合的综合练习:Poker牌
/* 刘意教程示例:*/ package cn.onecool.cot; import java.util.ArrayList; import java.util.Collections; impor ...
- 使用Nginx实现灰度发布
灰度发布是指在黑与白之间,能够平滑过渡的一种发布方式.AB test就是一种灰度发布方式,让一部分用户继续用A,一部分用户开始用B,如果用户对B没有什么反对意见,那么逐步扩大范围,把所有用户都迁移到B ...
- 平面上给定n条线段,找出一个点,使这个点到这n条线段的距离和最小。
题目:平面上给定n条线段,找出一个点,使这个点到这n条线段的距离和最小. 源码如下: #include <iostream> #include <string.h> #incl ...
- 2、flask之基础知识点
本篇导航: 路由系统 视图函数 请求与响应 模版语法 session 蓝图(blueprint).闪现 (flash) 扩展 一.路由系统 1.可传入参数: @app.route('/user/< ...
- js “top、clientTop、scrollTop、offsetTop…”
当要做一些与位置相关的插件或效果的时候,像top.clientTop.scrollTop.offsetTop.scrollHeight.clientHeight.offsetParent...看到这么 ...