该值指示指定的 System.String 对象是否出现在此字符串中 bool isContains = contain
在 C# 中,string 关键字来声明一个字符串变量,是 System.String 类的别号!
1.public string[] Split( params char[] separator )
返回一个字符串数组,包罗当前的 string 东西中的子字符串,子字符串是使用指定的 Unicode 字符数组中的元素进行分隔断绝分手的
2.public static bool IsNullOrEmpty( string value )
指示指定的字符串是否为 null 或者是否为一个空的字符串
3.public static string Format( string format, Object arg0 )
把指定字符串中一个或多个格局项替换为指定东西的字符串暗示形式
4.public bool Contains( string value )
返回一个暗示指定 string 东西是否呈此刻字符串中的值
5.public string Trim()
移除当前 String 东西中的所有前导空白字符和后置空白字符
6.public string[] Split( char[] separator, int count )
返回一个字符串数组,,包罗当前的 string 东西中的子字符串,子字符串是使用指定的 Unicode 字符数组中的元素进行分隔断绝分手的。int 参数指定要返回的子字符串的最大数目
string strSQL = "select * from {0}"; //将指定字符串中的一个或多个格局项替换为指定东西的字符串暗示形式 string strTempSQL = string.Format(strSQL, "Users"); Console.WriteLine(strTempSQL); string containsStr="playGames"; //返回一个值,该值指示指定的 System.String 东西是否呈此刻此字符串中 bool isContains = containsStr.Contains("Ga"); //指示指定的字符串是 null 还是 System.String.Empty 字符串 bool isNull = string.IsNullOrEmpty(containsStr); Console.WriteLine(isContains); Console.WriteLine(isNull); string splitStr = "str,yyx,jtx"; //返回的字符串数组包罗此实例中的子字符串(由指定 Unicode 字符数组的元素分隔断绝分手) string[] str = splitStr.Split(‘,‘); foreach(string strChar in str){ Console.WriteLine(strChar); } string trimStr = "str yyx jtx "; Console.WriteLine(trimStr.Trim());
温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/35003.html
- 上一篇:C#内存打点和垃圾回收机制
- 下一篇:对比新建的和报错的项目