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) |
相关文章
- Mac OS X完整卸载Node.js,并重新安装的方法
- 让你的作品更出色——词云Word Cloud的制作方法(基于python,WordCloud,stylecloud)
- 两个月15斤以上的健康减脂减重法,与饥饿、运动等无关的自我实验的验证方法(第二篇)...
- 好的提高代码质量的方法有哪些?有什么经验和技巧?
- Java 缺失的特性:扩展方法
- Java 定时线程池各个方法的区别 Java周期执行线程池各个方法的区别 ScheduledExecutorService schedulerService
- 常见的js加密/js解密方法
- pytest学习和使用23-通俗易懂的聊聊allure常用特性集合及使用方法说明
- PyTorch 之 简介、相关软件框架、基本使用方法、tensor 的几种形状和 autograd 机制
- 手机解锁方法:8个*的 Android 手机解锁软件