Array.Sort(vv, string.CompareOrdinal); //ASCII排序
 string[] words = { "The", "1quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog." };
string stTest = "IteststringUsing12date,when i was in";
//Concat把字符串数组合并成一个字符串
var unreadablePhrase = string.Concat(words);
Console.WriteLine(unreadablePhrase); //合并多个字符窜
Console.WriteLine(string.Concat("i like "," watch"," tv")); //Sort字符窜数组排序 sort 默认用ASCII
Array.Sort(words);
Array.Sort(words, string.CompareOrdinal); //ASCII排序
foreach (var i in words)
{ Console.WriteLine(i); } //Join给字符窜数组每个成员添加一个字符窜
var readablePhrase = string.Join("-ok", words);
System.Console.WriteLine(readablePhrase); //Reverse字符串反转顺序
char[] chars= stTest.ToCharArray();
Array.Reverse(chars);
Console.WriteLine( chars); //Remove 字符串删除 删除以12开始的2个字符
Console.WriteLine(stTest.Remove(stTest.IndexOf("12"),2)); //Replace 替换 把12替换成13
Console.WriteLine(stTest.Replace("12","13")); //Split给字符窜分组
string[] slistr = stTest.Split(',');
foreach (var i in slistr)
{ Console.WriteLine(i); } Console.WriteLine(stTest.ToLowerInvariant()); //区域性小写
Console.WriteLine(stTest.ToUpperInvariant());// //区域性大写
Console.WriteLine(stTest.ToUpper());// //区域性大写 // Substring(字符串提取): string newstring1 = stTest.Substring(30);//从startIndex位置开始,提取此位置后所有的字符(包括当前位置所指定的字符)。
string newstring2 = stTest.Substring(30,3);// 从startIndex位置开始,提取count个字符。
Console.WriteLine(newstring1); //即:was in
Console.WriteLine(newstring2); //即:was // Trim(字符串提取): stTest.Trim();//将字符串对象包含的字符串两边的空格去掉后返回。
Console.WriteLine(stTest.Trim('I')); ////寻找st字符串中开始与末尾是否有与'a'匹配,如有,将其移除 //字符串比较的几种形式========================================================================================================================================
//StringComparsionTpye1、Equals(是否相等) public bool Equals (string value) 比较调用方法的字符串对象包含字符串和参数给出的对象是否相同,如相同,就返回true,反之,返回false。
string equalstr = "comparision";
string comparisionStr = "Comparision";
bool equalstrb = equalstr.Equals("Comparision");//.Equals的一个非常重要的例外是使用序数(逐字节)比较。 这通过设计导致各种字符串函数的行为因计算机文化而异。
Console.WriteLine(equalstrb);//即:false //StringComparsionTpye2、CompareTo、Compare(是否相等)
Console.WriteLine(equalstr.CompareTo(comparisionStr));//-1
Console.WriteLine(string.Compare(equalstr, comparisionStr));//-1 Console.WriteLine(string.Compare(equalstr, comparisionStr, StringComparison.OrdinalIgnoreCase));//0 忽略大小写
Console.WriteLine((int)('A')); // Contains(判断是否包含)public bool Contains(string text):如果字符串中出现text,则返回true,反之false,如果text为("")也返回true。
string Containsst = "语文数学英语";
bool Containsb = Containsst.Contains("语文");
Console.WriteLine(Containsb);//true //Insert(字符串插入) public string Insert ( int startIndex, string value ):在指定的字符串下标为startIndex前插入字符串value。返回插入后的值。
string st = "语文数学英语abc";
string newst = st.Insert(6, "物理");//注:在指定索引“前”插入。
Console.WriteLine(newst);//即:语文数学英语物理abc /* EndsWith,StartsWith(判断字符串的开始或结束)
public bool EndsWith(string value):判断对象包含字符串是否以value指定的字符串结束,是则为 true;否则为 false。
public bool EndsWith(string value, StringComparison comparisonType):第二个参数设置比较时区域、大小写和排序规则。
public bool StartsWith(string value):判断对象包含字符串是否以value指定的字符串开始,是则为 true;否则为 false。
public bool StartsWith(string value, StringComparison comparisonType) :第二个参数设置比较时区域、大小写和排序规则。*/
string stt = "语文数学英语abc";
bool b = stt.EndsWith("英语ABC", StringComparison.CurrentCultureIgnoreCase);//第二个参数忽略大小比较。
Console.WriteLine(b);//true Console.WriteLine(DateTime.Now.ToString(CultureInfo.InvariantCulture)); // Console.WriteLine(CultureInfo.InvariantCulture.DateTimeFormat.ShortDatePatter); Decimal moneys = 12355m;
Console.WriteLine(moneys.ToString("C",new CultureInfo("en-US")));
Console.WriteLine(moneys.ToString("C", CultureInfo.InvariantCulture));

字符串按Ascii排序

string 字符串的操作 大全类的使用的更多相关文章

  1. String字符串相关操作

    .length 字符串长度.equals 比较字符串.equalIgnoreCase 比较字符串不区别大小写.charAt 获取字符串指定下标位置的字符.contains 判断字符串内是否包含某字符串 ...

  2. 4.String字符串类型操作

    String类型操作 1.set key value 设置key对应的值为string类型的value  2.mset key1 value1 … keyN valueN 一次设置多个key的值 3. ...

  3. String字符串的操作

    字符串的常用操作 # Author:nadech name = "my name is nadech" print(name.count("a")) print ...

  4. string字符串js操作

    String 对象方法 方法 描述 anchor() 创建 HTML 锚. big() 用大号字体显示字符串. blink() 显示闪动字符串. bold() 使用粗体显示字符串. charAt() ...

  5. String - 字符串分割操作

    如果我想将一个字符串按照每8位一组分为若干个块,然后存储在一个byte[ ]数组中,我首先需要确定这个byte数组的长度,但由于我无法确定这个字符串的长度是否可以被8整除,所以无法直接判断,因此需要对 ...

  6. 【超值分享】为何写服务器程序需要自己管理内存,从改造std::string字符串操作说起。。。

    服务器程序为何要进行内存管理,管中窥豹,让我们从string字符串的操作说起...... new/delete是用于c++中的动态内存管理函数,而malloc/free在c++和c中都可以使用,本质上 ...

  7. string字符串转数组

    /** * THis_is_a_cat * This Is A Cat * * Cat A Is This * @author Administrator * */ public class Test ...

  8. C风格字符串和C++ string 对象赋值操作的性能比较

    <<C++ Primer>> 第四版 Exercise Section 4.3.1 部分Exercise 4.2.9 习题如下: 在自己本机执行如下程序,记录程序执行时间: # ...

  9. redis:string字符串类型的操作

    1. string字符串类型的操作: 1.1. set 设置单个值 语法:set key value [EX seconds] [PX milliseconds] [NX|XX] 注: EX seco ...

随机推荐

  1. golang中channel讲解

    1. 无缓冲通道 2. 有缓冲通道 有缓冲通道特点:当channel已经满,在向里面写数据就会阻塞,当channel已经为空,在从里面读数据就会阻塞. 3. 关闭channel package mai ...

  2. golang中如何退出goroutine

    package main import ( "fmt" "runtime" "time" ) func main() { // 用gorou ...

  3. 【转载】Systemd 入门教程:实战篇

    作者: 阮一峰 日期: 2016年3月 8日 上一篇文章,我介绍了 Systemd 的主要命令,今天介绍如何使用它完成一些基本的任务. 一.开机启动 对于那些支持 Systemd 的软件,安装的时候, ...

  4. 从Apache官网下载Jar包步骤

    第一步:在官网找寻需要的包 Apache网址:http://commons.apache.org/ 在官网中,可以直接看到不同jar包的分类,如下图所示: 也可以点击官网左侧栏目里的 Release, ...

  5. UCB DS100 讲义《数据科学的原理与技巧》校对活动正式启动 | ApacheCN

    贡献指南:https://github.com/apachecn/ds100-textbook-zh/blob/master/CONTRIBUTING.md 整体进度:https://github.c ...

  6. 基础学习:关于this在派生类构造函数中的理解

    https://www.cnblogs.com/Bear-Study-Hard/archive/2006/01/09/313551.html 看了上面这篇文章有感,特做了个小样板,以加深对于this在 ...

  7. AT2163 [AGC006B] Median Pyramid Easy

    需要一点灵感的题目. 可以发现这样一个事情,当三个数中有两个数相同时,中为数一定是这两个相同的数. 基于这个观察,我们想让每一行都存在这样两个相同的两个数,就一定能保证第一层的值为 \(x\) 了. ...

  8. Git refusing to merge unrelated histories (拒绝合并不相关仓库)

    感谢原文作者:lindexi_gd 原文链接:https://blog.csdn.net/lindexi_gd/article/details/52554159 本文讲的是把git在最新2.9.2,合 ...

  9. JFrame 的层次结构 及 背景设置说明

    感谢原文:https://blog.csdn.net/qq_32006373/article/details/49659129 一.JFrame 的层次结构 我们通过两个图来说明一下 JFrame 的 ...

  10. Java 数组存储机制

    数组是一种引用类型. 数组用来存储类型相同的一组数据,一旦初始化完成,其所占的空间也确定下来了,即使清除某个元素,其所占用的空间仍然存在,即,数组的长度不能被改变,且数组只有在分配空间后才能使用. 数 ...