博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C# 字符串的操作
阅读量:4501 次
发布时间:2019-06-08

本文共 1228 字,大约阅读时间需要 4 分钟。

var tStr = "0|1:开门|2:关门|3:门检失败|4:开门|5:开门|6:关门";            var result = string.Format("[{0}]", string.Join(",", tStr.Substring(2).Split('|').Select(s => string.Format("{
{doorid:{0}, status:{1}}}", s.Split(':')[0], s.Split(':')[1]).Replace("开门", "1").Replace("关门", "0").Replace("门检失败", "-1")).ToArray())); MessageBox.Show(result); //string tStr = "0|1:开门|2:关门|3:门检失败|4:开门|5:开门|6:关门"; //tStr = tStr.Replace(":", ","); //tStr = tStr.Replace("开门", "status:1}"); //tStr = tStr.Replace("关门", "status:0}"); //tStr = tStr.Replace("门检失败", "status:-1}"); ////tStr = tStr.Replace("|", "{doorid:"); //string[] str = tStr.Split('|'); //string strs = "["; //for (int i = 1; i < str.Length; i++) //{ // MessageBox.Show(i.ToString()); // if (i < str.Length-1) // { // strs += "{doorid:" + str[i] + ","; // } else if( i== str.Length - 1) // { // strs += "{doorid:" + str[i] + "]"; // } //} //MessageBox.Show(strs);
View Code

 

转载于:https://www.cnblogs.com/aijiao/p/10606661.html

你可能感兴趣的文章
FB面经 Prepare: K closest point to the origin
查看>>
Android Handler Demo
查看>>
iOS网络基础
查看>>
最新dedecms网页游戏开服表发号网站源码模板
查看>>
在win7下配置sql2005允许远程访问
查看>>
aspose.cell 设置excel里面的文字是超链接
查看>>
POJ 1067 取石子游戏
查看>>
django开发框架-view & template
查看>>
[Linux]systemd和sysV
查看>>
时间日期正则表达
查看>>
JSON.NET 简单的使用
查看>>
java 集合 HashMap
查看>>
三栏宽度自适应布局的三种方法及其优缺点
查看>>
实训作业1
查看>>
日期控件 DatePicker 在ie8不能用
查看>>
多个表左联,要返回全部的结果,解决不能用where的问题
查看>>
hibernate left join fetch 出错的问题
查看>>
ifconfig,netstat command not found
查看>>
插入多个背景音乐
查看>>
监听url
查看>>