Function

Description

Example

CompareTo()

Compares one string to another

("Hello").CompareTo("Hello")

Contains()

Returns "True" if a specified comparison string is in a string or if the comparison string is empty

("Hello").Contains("ll")

CopyTo()

Copies part of a string to another string

$a = ("Hello World").toCharArray()
("User!").CopyTo(0, $a, 6, 5)
$a

EndsWith()

Tests whether the string ends with a specified string

("Hello").EndsWith("lo")

Equals()

Tests whether one string is identical to another string

("Hello").Equals($a)

IndexOf()

Returns the index of the first occurrence of a comparison string

("Hello").IndexOf("l")

IndexOfAny()

Returns the index of the first occurrence of any character in a comparison string

("Hello").IndexOfAny("loe")

Insert()

Inserts new string at a specified index in an existing string

("Hello World").Insert(6, "brave ")

GetEnumerator()

Retrieves a new object that can enumerate all characters of a string

("Hello").GetEnumerator()

LastIndexOf()

Finds the index of the last occurrence of a specified character

("Hello").LastIndexOf("l")

LastIndexOfAny()

Finds the index of the last occurrence of any character of a specified string

("Hello").LastIndexOfAny("loe")

PadLeft()

Pads a string to a specified length and adds blank characters to the left (right-aligned string)

("Hello").PadLeft(10)

PadRight()

Pads string to a specified length and adds blank characters to the right (left-aligned string)

("Hello").PadRight(10) + "World!"

Remove()

Removes any requested number of characters starting from a specified position

("Hello World").Remove(5,6)

Replace()

Replaces a character with another character

("Hello World").Replace("l", "x")

Split()

Converts a string with specified splitting points into an array

("Hello World").Split("l")

StartsWith()

Tests whether a string begins with a specified character

("Hello World").StartsWith("He")

Substring()

Extracts characters from a string

("Hello World").Substring(4, 3)

ToCharArray()

Converts a string into a character array

("Hello World").toCharArray()

ToLower()

Converts a string to lowercase

("Hello World").toLower()

ToLowerInvariant()

Converts a string to lowercase using casing rules of the invariant language

("Hello World").toLowerInvariant()

ToUpper()

Converts a string to uppercase

("Hello World").toUpper()

ToUpperInvariant()

Converts a string to uppercase using casing rules of the invariant language

("Hello World").ToUpperInvariant()

Trim()

Removes blank characters to the right and left

(" Hello ").Trim() + "World"

TrimEnd()

Removes blank characters to the right

(" Hello ").TrimEnd() + "World"

TrimStart()

Removes blank characters to the left

(" Hello ").TrimStart() + "World"

Chars()

Provides a character at the specified position

("Hello").Chars(0)

String对象的方法的更多相关文章

  1. JavaScript -- 时光流逝(三):js中的 String 对象的方法

    JavaScript -- 知识点回顾篇(三):js中的 String 对象的方法 (1) anchor(): 创建 HTML 锚. <script type="text/javasc ...

  2. cb18a_c++_修改string对象的方法

    cb18a_c++_修改string对象的方法s.insert(p,t)s.insert(p, 'A'); //迭代器前插入As.insert<p,n,t)s.insert(p, 3, 'B') ...

  3. cb17a_c++_构造string对象的方法

    cb17a_c++_构造string对象的方法string sstring s(s2)string s("value")string s(n,'c')string s(b,e) / ...

  4. JavaScript 字符串(String)对象的方法

    anchor() 描述:用于创建 HTML 锚 原型:stringObject.anchor(anchorname) 用法: <script> var txt="Hello wo ...

  5. JavaScript中String对象的方法介绍

    1.字符方法 1.1 charAt() 方法,返回字符串中指定位置的字符. var question = "Do you like JavaScript?"; alert(ques ...

  6. JavaScript中的string对象及方法

    string对象 string对象的两种创建 var a="hello"; var b=new String("hello"); //下面是方法 //charA ...

  7. [JS]给String对象添加方法,使传入的字符串字符之间以空格分开输出

    看到一个这样子的面试题: 给String对象添加一个方法,传入一个string类型的参数,然后将string的每一个字符间加空格返回,例如:addSpace("hello world&quo ...

  8. 在js中 把 json对象转化为String对象的方法

    方法1: 使用js的扩展方法 ** * json对象转字符串形式 */ function json2str(o) { var arr = []; var fmt = function(s) { if ...

  9. JS支持正则表达式的 String 对象的方法

    注意:本文中所有方法的 RegExp 类型的参数,其实都支持传入 String 类型的参数,JS会直接进行字符串匹配. (相当于用一个简单的非全局正则表达式进行匹配,但字符串并没有转换成 RegExp ...

  10. String 对象-->fromCharCode() 方法

    1.定义和用法 将ASCII码转换成对应的字符 语法: String.fromCharCode(n1, n2, ..., nX) 参数: n1, n2, ..., nX:一个或多个 Unicode 值 ...

随机推荐

  1. linux网络编程_1

    本文属于转载,稍有改动,以利于学习. (一)Linux网络编程--网络知识介绍 Linux网络编程--网络知识介绍客户端和服务端         网络程序和普通的程序有一个最大的区别是网络程序是由两个 ...

  2. php 面向对象的方式访问数据库

    <body> <?php //面向对象的方式访问数据库 //造对象 $db = new MySQLi("localhost","root",& ...

  3. Ubuntu下中文显示乱码

    转自:http://jingyan.baidu.com/article/915fc414c9d2ef51384b204c.html 装好了Ubuntu 13.10 后,打开部分Windows下的txt ...

  4. IOS项目自动构建

    # Sets the target folders and the final framework product. # 如果工程名称和Framework的Target名称不一样的话,要自定义FMKN ...

  5. Java Hour 22 I/O

    有句名言,叫做10000小时成为某一个领域的专家.姑且不辩论这句话是否正确,让我们到达10000小时的时候再回头来看吧. I/O InputStream, OutStream, Reader, Wri ...

  6. oracle体系结构详细示意图

  7. SOAPFaultException

    javax.xml.ws.soap.SOAPFaultException: String index out of range: -6 at org.apache.cxf.jaxws.JaxWsCli ...

  8. strcat函数造成的段错误(Segmentation fault)

    转自:http://book.51cto.com/art/201311/419441.htm 3.21  strcat函数造成的段错误 代码示例 int main() { char dest[7]=& ...

  9. 详细剖析电脑hosts文件的作用和修改

    提到电脑系统中的hosts文件,如果不是太熟悉的话,还真是闻所未闻,一是由于系统的hosts文件为系统属性,在系统默认设置下,我们根本无法看到它的存在,而是由于身处系统深层文件夹内,我们一般也无法察觉 ...

  10. centOS下安装node4.x

    在以前 Node 0.x 的时候,只需要通过 yum install -y nodejs 就可以把 Node 安装好了.但是 yum 安装的 Node 只能安装到 0.10.40 版的,并不能安装到 ...