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. canvas API ,通俗的canvas基础知识(二)

    上文我们讲到了画一条线,画矩形,写文字,总算是有了一个好的开头,如果还没有看的同学出门左转,先看看那篇,这里就不多做叙述了,接下来我们看比较复杂的一些属性和方法! 讲之前呢,我还是想温习一下,毕竟上文 ...

  2. HDU1695 GCD (欧拉函数+容斥原理)

    F - GCD Time Limit:3000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Stat ...

  3. SQL 删除存在于A表但是不存在B表中的记录

    目的是是的A表和B表某一个列集合相等 delete from A where tagetColumn not in ( select targetColumn from B)

  4. 【2016-08-06】QTableWidget的一些用法总结

    1. QTableWidget的列宽如何自适应显示区域大小? QTableWidget的列头继承自QHeaderView,因此如果不使用固定列宽而需要Table中多列的列宽自适应显示区域大小的话, 可 ...

  5. js 在myeclipse中报错

    转myeclipse中的js文件报错   整理一下,希望帮到 遇到此问题的哥们.姐们. 方法一:myeclipse9 很特殊 和 myeclipse10 不一样,所以myeclipse9 不能使用该方 ...

  6. stsadm.exe

    Usage: stsadm.exe -o <operation> [<parameters>] stsadm.exe -help [<operation>] Ope ...

  7. 无线ap和路由器wifi热点怎么区分和区别

    转自:http://blog.sina.com.cn/s/blog_5a6efa330101yrzh.html 有的人发现无线ap和无线路由器都可以实现无线上网,于是到无线市场买了个相当便宜的无线ap ...

  8. 2016国产开源软件TOP100(Q1)

    随着互联网的发展.开放标准的普及和虚拟化技术的应用等诸多IT新领域的创新及拓展,开源技术凭借其开放性.低成本.稳定性.灵活性.安全性和技术创新性等特点迅速走向成熟,逐步发展成为一种主流模式,日益改变着 ...

  9. 蓝桥杯 算法训练 区间k大数查询(水题)

    算法训练 区间k大数查询 时间限制:1.0s   内存限制:256.0MB 问题描述 给定一个序列,每次询问序列中第l个数到第r个数中第K大的数是哪个. 输入格式 第一行包含一个数n,表示序列长度. ...

  10. jquery笔记(仅供个人参考)

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...