我们可以讲字符串看做是char类型的一个只读数组。
ToCharArray();将字符串转换为char数组
new string(char[] chs):能够将char数组转换为字符串

1)、Length:获得当前字符串中字符的个数
2)、ToUpper():将字符转换成大写形式
3)、ToLower():将字符串转换成小写形式
4)、Equals(lessonTwo,StringComparison.OrdinalIgnoreCase):比较两个字符串,可以忽略大小写
5)、Split():分割字符串,返回字符串类型的数组。
6)、Substring():解决字符串。在截取的时候包含要截取的那个位置。
7)、IndexOf():判断某个字符串在字符串中第一次出现的位置,如果没有返回-1、值类型和引用类型在内存上存储的地方不一样。
8)、LastIndexOf():判断某个字符串在字符串中最后一次出现的位置,如果没有同样返回-1
9)、StartsWith():判断以....开始
10)、EndsWith():判断以...结束
11)、Replace():将字符串中某个字符串替换成一个新的字符串
12)、Contains():判断某个字符串是否包含指定的字符串
13)、Trim():去掉字符串中前后的空格
14)、TrimEnd():去掉字符串中结尾的空格
15)、TrimStart():去掉字符串中前面的空格
16)、string.IsNullOrEmpty():判断一个字符串是否为空或者为null
17)、string.Join():将数组按照指定的字符串连接,返回一个字符串。

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace 字符串
{
class Program
{
static void Main(string[] args)
{
//练习一:接收用户输入的字符串,将其中的字符以与输入相反的顺序输出。
string str = "abcdefg";
//倒叙循环
//for (int i = str.Length-1; i >=0; i--)
//{
// Console.Write(str[i]);
//}
//Console.ReadKey();
char[] chs=str.ToCharArray();
for (int i = ; i < chs.Length/; i++)
{
char temp = chs[i];
chs[i] = chs[chs.Length--i];
chs[chs.Length - - i] = temp;
}
str = new string(chs);
Console.WriteLine(str);
Console.ReadKey();
}
}
}
 using System.Text;
using System.Threading.Tasks; namespace 字符串
{
class Program
{
static void Main(string[] args)
{
//练习一:"hello c sharp"------"sharp c hello"。
string str = "hello c sharp";
string[] strNew=str.Split(new char[] { ' '},StringSplitOptions.RemoveEmptyEntries);
for (int i = ; i < strNew.Length/; i++)
{
string temp = strNew[i];
strNew[i] = strNew[strNew.Length - - i];
strNew[strNew.Length - - i] = temp;
}
for (int i = ; i < strNew.Length; i++)
{
Console.Write(strNew[i]+'\t');
}
Console.ReadKey();
}
}
}

最新文章

  1. tshark 抓包分析
  2. mongoDB01 介绍
  3. KVM虚拟机virsh常用参数
  4. UISlider
  5. WindowXP与WIN7环境安装、破解、配置AppScan8.0
  6. JSP基本语法
  7. php下载文件的一种方式
  8. tcp/ip 卷一 读书笔记(1)tcp/ip 概述
  9. linux利用ssh远程执行多台机器执行同样的命令
  10. 荣耀7.0系统手机最简单激活Xposed框架的步骤
  11. Linux之命令进阶
  12. Arch Linux中使用VMware Workstation不能打开vmmon内核模块
  13. BZOJ4962 : 简单的字符串
  14. linux下nodejs的安装
  15. knn/kmeans/kmeans++/Mini Batch K-means/Affinity Propagation/Mean Shift/层次聚类/DBSCAN 区别
  16. 后续使用dubbo的必要性的思考
  17. 【凯子哥带你夯实应用层】使用ActionMode实现有删除动画的多选删除功能
  18. 两个栈实现队列 Python实现
  19. win10 uwp 商业游戏
  20. POJ 3278 Catch That Cow (附有Runtime Error和Wrong Answer的常见原因)

热门文章

  1. 大数据学习之旅2——从零开始搭hadoop完全分布式集群
  2. 前端项目优化 -Web 开发常用优化方案、Vue &amp; React 项目优化
  3. (二)c#Winform自定义控件-按钮
  4. React Native 生命周期及相关方法小技巧使用
  5. 如何美观地打印 Python 对象?这个标准库可以简单实现
  6. JS如何重写一个函数
  7. [Python] 常见的排序与搜索算法
  8. Git 上传本地项目到Github
  9. Mysql高手系列 - 第4天:DDL常见操作汇总
  10. Python 基础(五)