/*
-
- 将下方给定的字符串根据分隔符拆分成字符串数组,数组每个元素均为一个单词。将该字符串数组按升序排序,并输出该字符串数组的内容。
With Microsoft Azure, you have a gallery of open source options. Code in Ruby, Python, Java, PHP, and Node.js. Build on Windows, iOS, Linux, and more.
- 将下方给定的字符串根据分隔符拆分成字符串数组,数组每个元素均为一个单词。将该字符串数组按升序排序,并输出该字符串数组的内容。
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace exp602
{
class Program
{
static void Main(string[] args)
{
string s1="With Microsoft Azure, you have a gallery of open source options. Code in Ruby, Python, Java, PHP, and Node.js. Build on Windows, iOS, Linux, and more.";
string[] s2= s1.Split(new string[]{" ", ",", "."},StringSplitOptions.RemoveEmptyEntries); //去掉空格,逗号,句号
string s3=null;
foreach (var item in s2)
{
s3 = s3 + item; //把去掉空格,逗号,句号的字符串数组连接成字符串
}
char[] s = s3.ToCharArray(); //利用string 类里的ToCharArray()方法把字符串分割成单个字母
foreach (var item in s.OrderBy(x=>x))//OrderBy里的是Lambda表达式
{
Console.Write("\t{0}",item);
}
}
}
}