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. PHP--TP框架----生成验证码的方式

    TP框架----生成验证码的方式 xianshi.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN& ...

  2. HDU 1452 Happy 2004 (逆元+快速幂+积性函数)

    G - Happy 2004 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Subm ...

  3. Ubuntu下中文显示乱码

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

  4. 模型验证组件——FluentValidation

    之前在博客园有幸从网友那里得知一个C#的模型验证组件(哈 不知道这样表述正确不),组件的功能比较简单,主要是实现了对Model的验证,例如验证用户名是否为空,密码长度是不是多余6个字符,当然还有其他更 ...

  5. Java Hour 20 Spring

    有句名言,叫做10000小时成为某一个领域的专家.姑且不辩论这句话是否正确,让我们到达10000小时的时候再回头来看吧. 本文作者Java 现经验约为20 Hour,请各位不吝赐教. 今天心情不佳,只 ...

  6. [译] UML中的关系之Dependency

    在UML中,依赖关系表示Client依赖于另一个元素,叫做Supplier. 通常来说,依赖关系不需要特殊的名字. 依赖的类别 抽象 abstraction, derive, refine, trac ...

  7. yum与rpm的使用

    rpm常用的命令组合: rpm -ivh:安装显示安装进度--install--verbose--hash -Uvh:升级软件包--Update: -qpl:列出RPM软件包内的文件信息[Query ...

  8. AndroidManifest.xml相关知识

    AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest  ...

  9. 4KB对齐

    4KB是固态硬盘的读写基本block size的大小也就是说读写的基本单位是4KB,哪怕1B的内容读写实际操作也是操作了4KB的块实际操作是以块为单位的 假设我的读写起始点刚好定在两个4KB大小的物理 ...

  10. 了解Json

    Json(JavaScript Object Notation) 是一种轻量级的数据交换格式,它是基于JavaScript的一个子集. 数据格式简单, 易于读写, 占用带宽小. {'age':'12' ...