C# List<string>和ArrayList用指定的分隔符分隔成字符串

串联字符串数组的所有元素,其中在每个元素之间使用指定的分隔符

 1             List<string> arr = new List<string>();
 2             arr.Add("好玩1");
 3             arr.Add("好玩1");
 4             arr.Add("好玩1");
 5             string str = string.Join(",", arr.ToArray());
 6
 7             ArrayList arr1 = new ArrayList();
 8             arr1.Add("好玩1");
 9             arr1.Add("好玩2");
10             arr1.Add("好玩3");
11             string str1 = string.Join(",", arr1.ToArray(typeof(string)) as string[]);
时间: 2024-08-29 00:18:32

C# List<string>和ArrayList用指定的分隔符分隔成字符串的相关文章

stl string 使用指定的分隔符分割成数个子字符串

#include <iostream> #include <vector> #include <string> #include <algorithm> using namespace std; void StringSplit(const string& str,vector<string>& vStr,const char& division) { int startPos = 0; int endPos = stri

String、String[]、ArrayList&lt;String&gt;之间的转换

1. ArrayList<String> 转换为 String[]: ArrayList<String>  list = new ArrayList<>(); list.add("aaa"); list.add("bbb"); String[] arrString = (String[])list.toArray() ; 2. String[] 转换为 ArrayList<String>: ArrayList<S

(华为)按照指定规则对输入的字符串进行处理

问题详细描述:将输入的两个字符串合并. 对合并后的字符串进行排序,要求为:下标为奇数的字符和下标为偶数的字符分别从小到大排序.这里的下标意思是字符在字符串中的位置. 对排训后的字符串进行操作,如果字符为'0'--'9'或者'A'--'F'或者'a'--'f',则对他们所代表的16进制的数进行BIT倒序的操作,并转换为相应的大写字符.如字符为'4',为0100b,则翻转后为0010b,也就是2.转换后的字符为'2': 如字符为'7',为0111b,则翻转后为1110b,也就是e.转换后的字符为大写

C#利用String类的IndexOf、LastIndexOf、Substring截取字符串

一.String.IndexOf String.IndexOf 方法 (Char, Int32, Int32)报告指定字符在此实例中的第一个匹配项的索引(从0开始).搜索从指定字符位置开始,并检查指定数量的字符位置.String.IndexOf(value, startIndex, count) 参数value:要查找的 Unicode 字符. startIndex:搜索起始位置. count:要检查的字符位置数.返回值(Int32):如果找到该字符,则为 value 的索引位置:否则如果未找到

c# 判断字符是否是全角, 获取字符串的字节数 , 获取字符串指定长度字节数的字符串

1 Encoding.Default.GetByteCount(checkString);  =2 全角 =1 半角 /// <summary> /// 获取字符串的字节长度 /// </summary> /// <param name="str"></param> /// <returns></returns> public static int GetStringByteLength(this string s

字符串按指定分隔符分隔

/// <summary> /// 字符串按指定分隔符分隔 /// </summary> /// <param name="str">字符串</param> /// <param name="separator">分隔符</param> /// <returns></returns> public List<string> ConvertToStringLis

js获取指定字符前/后的字符串简单实例

<!doctype html> <html> <head> <meta charset="utf-8"> <title>无标题文档</title> </head> <script type="text/javascript"> /* string 字符串; str 指定字符; split(),用于把一个字符串分割成字符串数组; split(str)[0],读取数组中索引为

shell 生成指定范围随机数与随机字符串 .

shell 生成指定范围随机数与随机字符串 分类:             shell              2014-04-22 22:17     20902人阅读     评论(5)     收藏     举报 shellrandomurandomuuidlinux shell 生成指定范围随机数与随机字符串 1.使用系统的 $RANDOM 变量 [plain] view plaincopyprint? [email protected]:~$ echo $RANDOM 17617 [

delphi 怎么将一个文件流转换成字符串(String到流,String到文件,相互转化)

//from   http://kingron.myetang.com/zsfunc0d.htm (*//   标题:充分利用pascal字符串类型   说明:和PChar不同,string可以保存#0字符在其中;示例文件.内存流字符串之间转换   设计:Zswang   日期:2002-01-25   支持:[email protected]   //*) ///////Begin   Source   function   StringToFile(mString:   string;