1、在.NET Framework中,字符总是表示成16位unicode代码值(关于unicode、utf8等可以到http://www.ruanyifeng.com/blog/2007/10/ascii_unicode_and_utf-8.html中查看)。2、在字符编码术语中,码位或编码位置,即英文的code point或code position,是组成码空间(或代码页)的数值。例如,ASCII码包含128个码位。3、System.String代表一个不可变的(immutable)顺序字符集。String类型直接派生自Object,所以是引用类型。因此,Strin...
1.字符串比较字符串.ComparTo(目标字符串)"a".ComparTo("b");2.查找子串字符串.IndexOf(子串,查找其实位置) ;字符串.LastIndexOf(子串) ;最后一次出现的位置str.IndexOf("ab",0);3.插入子串字符串.Insert(插入位置,插入子串) ;s.Insert(2,"ab");4.移出子串字符串.Remove(其实位置,移出数);s.Remove(3,2);5.替换子串字符串.Replace(源子串,替换为);s.Replace("-"," ");将-替换为空格6.截取子串字符串.Substring(截取其实位...
正常字符串的string.format是没问题的但是在拼接json的字符串的时候因为里面包含了 {} 花括号 里面又嵌套了 {0} {1} {2}这些要替换的关键字 所以会报错。经过百度。字符串中包含{或者},则需要用{{ 来代替字符 {,用}} 代替 }string strTemplate = "{{\"C0061_Code\":\"{0}\",\"C0061_Name\":\"{1}\",\"C0010_SCode\":\"{2}\",\"C0010_SName\":\"{3}\",\"Type\":\"{4}\"}},";//sb1.AppendFormat(strTemplate, row["C0061_Code"].T...
//Newtonsoft.Json 使用第三方类库将传入的Json字符串反序列化成实体类。List<Fpy> dataList = JsonConvert.DeserializeObject<List<Fpy>>(JsonConvert.SerializeObject(result));//然后 linq 排序dataList = dataList.OrderBy(p => p.AmbCode).ToList();//最后 c# 转化为 json 字符.string result2 = JsonConvert.SerializeObject(dataList); 原文:https://www.cnblogs.com/Nakago/p/14687882.html
转自:http://www.cnblogs.com/lcwzj/archive/2009/04/16/1436992.html当我们想要获得一个唯一的key的时候,通常会想到GUID。这个key非常的长,虽然我们在很多情况下这并不是个问题。但是当我们需要将这个36个字符的字符串放在URL中时,会使的URL非常的丑陋。 想要缩短GUID的长度而不牺牲它的唯一性是不可能的,但是如果我们能够接受一个16位的字符串的话是可以做出这个牺牲的。 我们可以将一个标准的GUID 21726045-e8f7...
在进行表设计的时候,表之间的关联关系有很多,而关联表的有用字段可能很少而且用到的数据量也不会太大,可以将关联的表变成字符串存储如:一个订单有多个供应商订单,那么可以吧供应商信息存储到订单表其中一个字段中 上述:同一行不同列使用 ~ 线分隔,不同行使用 | 分隔在借助字符串转换为dataTable 就可以得到一个被关联的供应商表了///<summary>/// 1~2|3~4 与DataTable的相互转化,colName列名集合///</summary>///<param nam...
借用DataTable的Compute函数进行计算。string formula = "1+1*4/3+23*(1+2)";
DataTable dt = new DataTable();
string really_data = dt.Compute(formula, "false").ToString(); 原文:https://www.cnblogs.com/LittleJin/p/9847696.html
1、字符串函数(1)使用串联运算符和 Visual Basic 常量可将多个字段组合在一起。以下表达式返回两个字段,它们分别位于同一文本框的不同行中:=Fields!FirstName.Value & vbCrLf & Fields!LastName.Value (2)使用 Format 函数可设置字符串中日期和数字的格式。下面的表达式以长日期格式显示 StartDate 和 EndDate 参数的值:=Format(Parameters!StartDate.Value, "D") & " through " & Format(Parameters!EndDate.Value, "D") (...
C#.NET 各种连接字符串近期连接数据库时,经常忘记连接字符串是如何的格式,现在此备注此文章引用http://www.cnblogs.com/zhiqiang-imagine/archive/2010/03/22/1691538.html且做了些补充1.C#连接连接Access 程序代码: using System.Data; using System.Data.OleDb; .. string strConnection="Provider=Microsoft.Jet.OleDb.4.0;"; strConnection+=@"Data Source=C:BegASPNETNorthwind.md...
string respDataJson = "A=&B=2&C=asdfasdf"; string respDataJson = "A=&B=2&C=asdfasdf"; var dddddd= StringToObject<ResponseModel>(respDataJson); publicstatic T StringToObject<T>(thisstring str) where T : new(){Type typeData = typeof(T);T entity = new T();System.Reflection.PropertyInfo[] proArray = typeData.GetProperties();var pairs = str.Split(‘&‘);foreach (var p in pairs){var items ...
///<summary>/// 截取中间字符
///</summary>///<param name="text">全字符串</param>///<param name="start">开始字符串 </param>///<param name="end">结束字符串 </param>///<returns></returns>publicstaticstring Substring(string text,string start,string end)
{Regex regex = new Regex("(?<=(" + start + "))[.\\s\\S]*?(?=(" + end + "))", RegexOptions.Multiline | RegexOptions.Singleline);return regex.Match(text...
字符串比较,strA.CompareTo(strB)A大于B 正数
A小于B 负数
A等于B 0string strA = "ab";
string strB = "jk";
int intResult = strA.CompareTo(strB);
Console.WriteLine(intResult);查找字符串的位置IndexOf,LastIndexOf,StartWith,EndWithstring str = "Hello world!";
int index = str.IndexOf('o');
int index = str.LastIndexOf('o');
int index = str.IndexOf("lo");
Console.WriteLine(index);格式化输出string strFormat ...
实例一:string result = "";string str = "大家好! <User EntryTime=‘2010-10-7‘ Email=‘zhangsan@163.com‘>张三</User> 自我介绍。";Regex regex = new Regex(@"<User\s*EntryTime=‘(?<time>[\s\S]*?)‘\s+Email=‘(?<email>[\s\S]*?)‘>(?<userName>[\s\S]*?)</User>", RegexOptions.IgnoreCase);Match match = regex.Match(str);if (match.Success){string userName = match.Groups["userName"].Value; //获取用户名strin...
1、格式化货币(跟系统的环境有关,中文系统默认格式化人民币,英文系统格式化美元)string.Format("{0:C}",0.2) 结果为:¥0.20 (英文操作系统结果:$0.20)默认格式化小数点后面保留两位小数,如果需要保留一位或者更多,可以指定位数 string.Format("{0:C1}",23.15) 结果为:¥23.2 (截取会自动四舍五入)格式化多个Object实例 string.Format("市场价:{0:C},优惠价{1:C}",23.15,19.82)2、格式化十进制的数字(格式化成固定的...
double temp=3.1415926;(F)Fixed point:string str1=temp.toString("f1");//保留一位小数 四舍五入 结果:3.1(F)Fixed point:string str2=temp.toString("f2");//保留两位小数,四舍五入 下面一次类推 结果:3.14(N)Number:string str2=temp.toString("N");//保留 结果:3.14(G)General (default):string str2=temp.toString("G");//保留 结果:3.1415926(P)Percent:string str2=temp.toString("P");//保留 结果:314.16%(E)Scient...