String对象的方法
|
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() |
|
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对象的方法的更多相关文章
- JavaScript -- 时光流逝(三):js中的 String 对象的方法
JavaScript -- 知识点回顾篇(三):js中的 String 对象的方法 (1) anchor(): 创建 HTML 锚. <script type="text/javasc ...
- cb18a_c++_修改string对象的方法
cb18a_c++_修改string对象的方法s.insert(p,t)s.insert(p, 'A'); //迭代器前插入As.insert<p,n,t)s.insert(p, 3, 'B') ...
- cb17a_c++_构造string对象的方法
cb17a_c++_构造string对象的方法string sstring s(s2)string s("value")string s(n,'c')string s(b,e) / ...
- JavaScript 字符串(String)对象的方法
anchor() 描述:用于创建 HTML 锚 原型:stringObject.anchor(anchorname) 用法: <script> var txt="Hello wo ...
- JavaScript中String对象的方法介绍
1.字符方法 1.1 charAt() 方法,返回字符串中指定位置的字符. var question = "Do you like JavaScript?"; alert(ques ...
- JavaScript中的string对象及方法
string对象 string对象的两种创建 var a="hello"; var b=new String("hello"); //下面是方法 //charA ...
- [JS]给String对象添加方法,使传入的字符串字符之间以空格分开输出
看到一个这样子的面试题: 给String对象添加一个方法,传入一个string类型的参数,然后将string的每一个字符间加空格返回,例如:addSpace("hello world&quo ...
- 在js中 把 json对象转化为String对象的方法
方法1: 使用js的扩展方法 ** * json对象转字符串形式 */ function json2str(o) { var arr = []; var fmt = function(s) { if ...
- JS支持正则表达式的 String 对象的方法
注意:本文中所有方法的 RegExp 类型的参数,其实都支持传入 String 类型的参数,JS会直接进行字符串匹配. (相当于用一个简单的非全局正则表达式进行匹配,但字符串并没有转换成 RegExp ...
- String 对象-->fromCharCode() 方法
1.定义和用法 将ASCII码转换成对应的字符 语法: String.fromCharCode(n1, n2, ..., nX) 参数: n1, n2, ..., nX:一个或多个 Unicode 值 ...
随机推荐
- poj 2421 Constructing Roads 解题报告
题目链接:http://poj.org/problem?id=2421 实际上又是考最小生成树的内容,也是用到kruskal算法.但稍稍有点不同的是,给出一些已连接的边,要在这些边存在的情况下,拓展出 ...
- 一个程序中关于多个osgGA::GUIEventHandler同时存在的问题
平时使用GUIEventHandler不太注意handle()函数的返回值,觉得返回true或者false都无所谓,其实不然. 我遇到的问题是程序中一个节点添加了GUIEventHandler对象pi ...
- Java 全半角转换
* 全角转半角的 转换函数* @return String*/public static final String full2HalfChange(String QJstr){StringBuffer ...
- MVC准备前基础知识
一.自动属性C#自动属性可以避免原来这样我们手工声明一个私有成员变量以及编写get/set逻辑public class Product{ public int Id { get; set; } pub ...
- jQuery常规选择器
//简单选择器$('div').css('color','red'); //元素选择器,返回多个元素$('#box').css('color','red');//id选择器,返回单个元素$('.box ...
- 配置redis外网可访问
redis采用的安全策略,默认会只准许本地访问 通过简单配置,完成允许外网访问 [root@cache01 conf]# egrep "(^bind|#bind|# bind)" ...
- Oracle 日常应用和操作笔记
简单整理oracle日常应用笔记. 1.采用excel表格中的数据直接粘贴数据库记录中,默认会在后面加一个空格“”,操作完成后一定要记得对空格匹配然后修改一下. 2.查询数据库里的所有表结构, 采用s ...
- 菜鸟学Linux命令:find命令 查找文件
find命令是Linux下最常用的命令之一,灵活的使用find命令,你会发现查找文件变得十分简单. 命令格式 find [指定查找目录] [查找规则(选项)] [查找完后执行的动作] 参数规则 - ...
- Linux下可以替代windows的软件汇总:(不断完善中)
http://www.ubuntukylin.com/ukylin/forum.php?mod=viewthread&tid=9530 原则:不求全面,只求实用.主要针对桌面级应用.网购: ...
- 13、在 uwp应用中,给图片添加高斯模糊滤镜效果(一)
如果在应用中,如果想要给app 添加模糊滤镜,可能第一想到的是第三方类库,比如 Win2d.lumia Imaging SDK .WriteableBitmapEx,不可否认,这些类库功能强大,效果也 ...