c中string,C#基础之string与StringBuild

string

1.string是一个引用类型,但使用起来像值类型
string str1 = "123";
string str2 = str1;
str2 = "456";
Console.WriteLine(str2);
2.string 的特点
A:字符串的不可变性
B:字符串的留用
C:注意“+”号的应用,拼接字符串,如果“+”号两边有准确的值,是不影响性能的,如果是不确定的,这种情况下就造成了资源浪费。要避免不确定字符串相加
D:字符串池--对直接字符串来说
3.string 的函数
Publicc中string,C#基础之string与StringBuild Supported by the .NET Compact Framework
Clone
返回对此 String 实例的引用。
Publicc中string,C#基础之string与StringBuild Static Supported by the .NET Compact Framework
Compare
已重载。 比较两个指定的 String 对象。
Publicc中string,C#基础之string与StringBuild Static
CompareOrdinal
已重载。 通过计算每个字符串中相应 Char 对象的数值来比较两个 String 对象。
Publicc中string,C#基础之string与StringBuild
CompareTo
已重载。 将此实例与指定的对象或 String 进行比较,并返回二者相对值的指示。
Publicc中string,C#基础之string与StringBuild Static Supported by the .NET Compact Framework
Concat
已重载。 连接 String 的一个或多个实例,或 Object 的一个或多个实例的值的 String 表示形式。
Publicc中string,C#基础之string与StringBuild
Contains
返回一个值,该值指示指定的 String 对象是否出现在此字符串中。
Publicc中string,C#基础之string与StringBuild Static Supported by the .NET Compact Framework
Copy
创建一个与指定的 String 具有相同值的 String 的新实例。
Publicc中string,C#基础之string与StringBuild Supported by the .NET Compact Framework
CopyTo
将指定数目的字符从此实例中的指定位置复制到 Unicode 字符数组中的指定位置。
Publicc中string,C#基础之string与StringBuild Supported by the .NET Compact Framework
EndsWith
已重载。 确定 String 的实例的末尾是否与指定的字符串匹配。
Publicc中string,C#基础之string与StringBuild Supported by the .NET Compact Framework
Equals
已重载。 已重写。 确定两个 String 对象是否具有相同的值。
Publicc中string,C#基础之string与StringBuild Static Supported by the .NET Compact Framework
Format
已重载。 将指定的 String 中的每个格式项替换为相应对象的值的文本等效项。
Publicc中string,C#基础之string与StringBuild
GetEnumerator
检索一个可以循环访问此字符串中的每个字符的对象。
Publicc中string,C#基础之string与StringBuild Supported by the .NET Compact Framework
GetHashCode
已重写。 返回该字符串的哈希代码。
Publicc中string,C#基础之string与StringBuild Supported by the .NET Compact Framework
GetType
获取当前实例的 Type。 (从 Object 继承。)
Publicc中string,C#基础之string与StringBuild Supported by the .NET Compact Framework
GetTypeCode
返回类 String 的 TypeCode。
Publicc中string,C#基础之string与StringBuild Supported by the .NET Compact Framework
IndexOf
已重载。 报告 String 或一个或多个字符在此字符串中的第一个匹配项的索引。
Publicc中string,C#基础之string与StringBuild Supported by the .NET Compact Framework
IndexOfAny
已重载。 报告指定 Unicode 字符数组中的任意字符在此实例中第一个匹配项的索引。
Publicc中string,C#基础之string与StringBuild Supported by the .NET Compact Framework
Insert
在此实例中的指定索引位置插入一个指定的 String 实例。
Publicc中string,C#基础之string与StringBuild Static Supported by the .NET Compact Framework
Intern
检索系统对指定 String 的引用。
Publicc中string,C#基础之string与StringBuild Static Supported by the .NET Compact Framework
IsInterned
检索对指定 String 的引用。
Publicc中string,C#基础之string与StringBuild
IsNormalized
已重载。 指示此字符串是否符合特定的 Unicode 范式。
Publicc中string,C#基础之string与StringBuild Static Supported by the .NET Compact Framework
IsNullOrEmpty
指示指定的 String 对象是 空引用(在 Visual Basic 中为 Nothing) 还是 Empty 字符串。
Publicc中string,C#基础之string与StringBuild Static Supported by the .NET Compact Framework
Join
已重载。 在指定 String 数组的每个元素之间串联指定的分隔符 String,从而产生单个串联的字符串。
Publicc中string,C#基础之string与StringBuild Supported by the .NET Compact Framework
LastIndexOf
已重载。 报告指定的 Unicode 字符或 String 在此实例中的最后一个匹配项的索引位置。
Publicc中string,C#基础之string与StringBuild Supported by the .NET Compact Framework
LastIndexOfAny
已重载。 报告在 Unicode 数组中指定的一个或多个字符在此实例中的最后一个匹配项的索引位置。
Publicc中string,C#基础之string与StringBuild
Normalize
已重载。 返回一个新字符串,其二进制表示形式符合特定的 Unicode 范式。
Publicc中string,C#基础之string与StringBuild Static Supported by the .NET Compact Framework
op_Equality
确定两个指定的 String 对象是否具有同一值。
Publicc中string,C#基础之string与StringBuild Static Supported by the .NET Compact Framework
op_Inequality
确定两个指定的 String 对象是否具有不同的值。
Publicc中string,C#基础之string与StringBuild Supported by the .NET Compact Framework
PadLeft
已重载。 右对齐此实例中的字符,在左边用空格或指定的 Unicode 字符填充以达到指定的总长度。
Publicc中string,C#基础之string与StringBuild Supported by the .NET Compact Framework
PadRight
已重载。 左对齐此字符串中的字符,在右边用空格或指定的 Unicode 字符填充以达到指定的总长度。
Publicc中string,C#基础之string与StringBuild Static Supported by the .NET Compact Framework
ReferenceEquals
确定指定的 Object 实例是否是相同的实例。 (从 Object 继承。)
Publicc中string,C#基础之string与StringBuild Supported by the .NET Compact Framework
Remove
已重载。 从此实例中删除指定个数的字符。
Publicc中string,C#基础之string与StringBuild Supported by the .NET Compact Framework
Replace
已重载。 将此实例中的指定 Unicode 字符或 String 的所有匹配项替换为其他指定的 Unicode 字符或 String
Publicc中string,C#基础之string与StringBuild Supported by the .NET Compact Framework
Split
已重载。 返回包含此实例中的子字符串(由指定 CharString 数组的元素分隔)的 String 数组。
Publicc中string,C#基础之string与StringBuild Supported by the .NET Compact Framework
StartsWith
已重载。 确定 String 实例的开头是否与指定的字符串匹配。
Publicc中string,C#基础之string与StringBuild Supported by the .NET Compact Framework
Substring
已重载。 从此实例检索子字符串。
Publicc中string,C#基础之string与StringBuild Supported by the .NET Compact Framework
ToCharArray
已重载。 将此实例中的字符复制到 Unicode 字符数组。
Publicc中string,C#基础之string与StringBuild Supported by the .NET Compact Framework
ToLower
已重载。 返回此 String 转换为小写形式的副本。
Publicc中string,C#基础之string与StringBuild
ToLowerInvariant
返回此 String 对象的转换为小写形式的副本,返回时使用固定区域性的大小写规则。
Publicc中string,C#基础之string与StringBuild Supported by the .NET Compact Framework
ToString
已重载。 已重写。 将此实例的值转换为 String
Publicc中string,C#基础之string与StringBuild Supported by the .NET Compact Framework
ToUpper
已重载。 返回此 String 转换为大写形式的副本。
Publicc中string,C#基础之string与StringBuild Supported by the .NET Compact Framework
ToUpperInvariant
返回此 String 对象的转换为大写形式的副本,返回时使用固定区域性的大小写规则。
Publicc中string,C#基础之string与StringBuild Supported by the .NET Compact Framework
Trim
已重载。 从此实例的开始位置和末尾移除一组指定字符的所有匹配项。
Publicc中string,C#基础之string与StringBuild Supported by the .NET Compact Framework
TrimEnd
从此实例的结尾移除数组中指定的一组字符的所有匹配项。
Publicc中string,C#基础之string与StringBuild Supported by the .NET Compact Framework
TrimStart
从此实例的开始位置移除数组中指定的一组字符的所有匹配项。

StringBuild

StringBuild内部维护着一个Char类型的数组
StringBuilder sb = new StringBuilder();
sb.Append("123");
sb.ToString();
StringBuild的函数

Append
已重载。 在此实例的结尾追加指定对象的字符串表示形式。
Publicc中string,C#基础之string与StringBuild Supported by the .NET Compact Framework
AppendFormat
已重载。 向此实例追加包含零个或更多格式规范的格式化字符串。每个格式规范由相应对象参数的字符串表示形式替换。
Publicc中string,C#基础之string与StringBuild
AppendLine
已重载。 将默认的行终止符(或指定字符串的副本和默认的行终止符)追加到此实例的末尾。
Publicc中string,C#基础之string与StringBuild
CopyTo
将此实例的指定段中的字符复制到目标 Char 数组的指定段中。
Publicc中string,C#基础之string与StringBuild Supported by the .NET Compact Framework
EnsureCapacity
确保 StringBuilder 的此实例的容量至少是指定值。
Publicc中string,C#基础之string与StringBuild Supported by the .NET Compact Framework
Equals
已重载。 返回一个值,该值指示此实例是否与指定的对象相等。
Publicc中string,C#基础之string与StringBuild Supported by the .NET Compact Framework
GetHashCode
用作特定类型的哈希函数。GetHashCode 适合在哈希算法和数据结构(如哈希表)中使用。 (从 Object 继承。)
Publicc中string,C#基础之string与StringBuild Supported by the .NET Compact Framework
GetType
获取当前实例的 Type。 (从 Object 继承。)
Publicc中string,C#基础之string与StringBuild Supported by the .NET Compact Framework
Insert
已重载。 将指定对象的字符串表示形式插入到此实例中的指定字符位置。
Publicc中string,C#基础之string与StringBuild Static Supported by the .NET Compact Framework
ReferenceEquals
确定指定的 Object 实例是否是相同的实例。 (从 Object 继承。)
Publicc中string,C#基础之string与StringBuild Supported by the .NET Compact Framework
Remove
将指定范围的字符从此实例中移除。
Publicc中string,C#基础之string与StringBuild Supported by the .NET Compact Framework
Replace
已重载。 将此实例中所有的指定字符或字符串替换为其他的指定字符或字符串。
Publicc中string,C#基础之string与StringBuild Supported by the .NET Compact Framework
ToString
已重载。 已重写。 将 StringBuilder 的值转换为 String。
Tags:  c中string

延伸阅读

最新评论

发表评论