c# Char && string

String str = [null]; 可以用此方法声明一个空字符串
str +"" + str1;
Int Compare(string a,string b)
Int Compare(string a,string b ,bool ignorCase) 第三方参数是true 忽略大小写
String.Compare("aaa","bbb");
int flag = str1.CompareTo("aab");
string a = "aab";
string b = "aac";
bool c = a.Equals(b);
Console.WriteLine(c);
string newstr = String.Format("aaa{0} bbb {1}","1","2");
Console.WriteLine(newstr);
String a = "abcdefg";
String b = ""; //我测试的 b字符串必须预先定义
b = a.Substring(1,4);
String a = "eeeabcdebcde";
char[] sep = {'a','c'};
String[] b = a.Split(sep);
for (int i = 0; i < sep.Length; i++) {
Console.WriteLine("item {0} {1}",i,b[i]);
}
String a = "abcdefg";
string b;
b = a.Insert(3,"hahaha");
String a = "abcdefg";
string b;
a = a.PadRight(9,'z');
a = a.Remove(3,2); //开始位置 从开始位置删除几个
String a = "abc";
String b;
b = String.Copy(a);
Public void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int count);
sourceIndex 需要复制的字符串起始位置
destination 目标字符数组
destinationIndex 制定目标数组中的开始存放位置
count 指定要复制的字符个数
例子:
String st1 = "用一生下载你";
char[] str = new char[100];
st1.CopyTo(1,str,0,4); //将字符串st从索引1开始的4个字符串复制到字符数组str中
异常:ArgumentOutOfRangeException
sourceIndex、destinationIndex 或 count 为负
count 大于从 startIndex 到此实例末尾的子字符串的长度
count 大于从 destinationIndex 到 destination 末尾的子数组的长度
public string Replace(char OChar,char NChar); 主要用于替换字符串中的字符
public string Replace(string Ovalue,string NValue); 主要用于替换字符串中的字符串
ochar 待替换的字符
nchar 替换后的新字符
ovalue 待替换的字符串
nvalue 替换后的新字符串
String str1 = "用一生下载你";
string b = str1.Replace('一','二'); 替换字符
string c = str1.Replace("用一生","去你妈的"); 替换字符串
c# Char && string的更多相关文章
- const char* && string && String^ 类型转换
const char* && string && String^ 类型转换 const char* ---> string const char * cw= &q ...
- const char* <----- > string
(1) const char* <----- string const char* const_txt_path=txt_path.c_str(); (2) string ...
- c#中 uint--byte[]--char[]--string相互转换汇总
原文:c#中 uint--byte[]--char[]--string相互转换汇总 在在做一些互操作的时候往往需要一些类型的相互转换,比如用c#访问win32api的时候往往需要向api中传入DWOR ...
- 【C语言】reverse_string(char * string)(递归)
递归reverse_string(char * string)性能. 逆转 原始字符串 更改 相反,打印出的. /* 编写一个函数reverse_string(char * string)(递归实现) ...
- MFC中char*,string和CString之间的转换
MFC中char*,string和CString之间的转换 一. 将CString类转换成char*(LPSTR)类型 方法一,使用强制转换.例如: CString theString( &q ...
- CString转char * ,string
CString头文件#include <afx.h> string头文件#include <string.h> 1.CString转char * CString cstr; c ...
- wchar_t char string wstring 之间的转换
wchar_t char string wstring 之间的转换 转:http://blog.csdn.net/lbd2008/article/details/8333583 在处理中文时有时需要进 ...
- VS2013 MFC C++ CString ,const char , char, string 类型转换
VS2013 测试 以下测试加入头文件: # include <string>#include <cstdlib>using namespace std; //-------- ...
- c++编写递归函数char *itostr (int n,char *string),该函数将整数n转换为十进制表示的字符串。
#include<iostream> #include<stdio.h> using namespace std; ; char *itostr (int n,char *St ...
- System::String *,char*,string 等的类型转换 [转]
在VC 的编程中,经常会用到各种类型的转换,在MFC中textbox等控件得到的返回类型是System::String *,而写入的文件要求是 const char *类型的,下面介绍一些转换的方法: ...
随机推荐
- Hadoop-MyEclipse安装配置
配置环境:Hadoop-1.2.1,MyEclipse,Centos6.5 网站上有很多关于Hadoop-eclipse的安装配置信息,但很少有讲到关于怎么在MyEclipse上配置Hadoop的相关 ...
- bootstrap-table表格插件的使用案例
近期刚刚结束一个项目,总结一下之前做的一个后台管理系统中用到的bootstrap-table表格插件,下面是我做的一个案例(展示主要代码部分): //请求服务数据时所传参数 function quer ...
- 克鲁斯卡尔(Kruskal)算法求最小生成树
/* *Kruskal算法求MST */ #include <iostream> #include <cstdio> #include <cstring> #inc ...
- A very hard Aoshu problem(dfs或者数位)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=4403 A very hard Aoshu problem Time Limit: 2000/1000 ...
- 安装myeclipse后,打开时弹出:“该站点安全证书的吊销证书不可用”,怎样解决?
1.当弹出"该站点安全证书的吊销信息不可用.是否继续?"的对话框时,点击"查看证书",切换到"详细信息"TAB页,找到其"CRL分 ...
- DFS算法(——模板习题与总结)
首先,需要说明的是搜索算法本质上也是枚举的一种,时间复杂度还是很高的,遇到问题(特别是有水平的比赛上),不要优先使用搜索算法. 这里总结一下DFS算法: 1.从图中某个顶点出发,访问v. 2.找出刚访 ...
- 学而精计算机公共基础学习之路TEST1
算法 一:算法基本概念 算法是个什么概念学了这么久的程序尽然没有听说过,其实算法就是为了解决问题那么怎么准确完整的解决这个问题就是算法.所以我们所写的程序就可以说为对算法的描述,但是程序编制是不能有于 ...
- dede list列表页和文章页分别使用if else
标签: dede 2015-01-25 19:33 755人阅读 评论(0) 收藏 举报 分类: [ Dede ](20) 版权声明:本文为博主原创文章,未经博主允许不得转载. list列表页中使用i ...
- 最大连接数:60 iops:150 什么概念?
最大连接数:最多允许同时多少个客户端连接到数据库 iops:每秒读写操作的次数 关于最大连接数: 假设一个时间点:00:01:00 00:01:01 -> 第一个客户端连接到数据 ...
- 系列3|走进Node.js之多进程模型
文:正龙(沪江网校Web前端工程师) 本文原创,转载请注明作者及出处 之前的文章"走进Node.js之HTTP实现分析"中,大家已经了解 Node.js 是如何处理 HTTP 请求 ...