C#中substring
和Java差不多。
在Java裡面:
String a = "abc";
a.substring(1)
就是"bc"。
C#中有兩個過載函式
舉例如下程式碼,VS2005編譯通過
using System;
using System.Collections.Generic;
using System.Text;
namespace sln_sub
{
class Program
{
static void Main(string[] args)
{
string myString = "A quick fox is jumping over the lazy dog";
//Substring()在C#中有兩個過載函式
//分別如下示例
string subString1 = myString.Substring(0);
//如果傳入引數為一個長整, 且大於等於0,
//則以這個長整的位置為起始,
//擷取之後餘下所有作為字串.
//如若傳入值小於0,
//系統會丟擲ArgumentOutOfRange異常
//表明引數範圍出界
string subString2 = myString.Substring(0, 11);
//如果傳入了兩個長整引數,
//前一個為引數子串在原串的起始位置
//後一個引數為子串的長度
//如不合條件同樣出現上述異常
Console.WriteLine(subString1);
Console.WriteLine(subString2);
Console.ReadLine();
}
}
}
程式輸出的結果:
A quick fox is jumping over the lazy dog
A quick fox
相關文章
- C# SubstringC#
- Js的substring和C#的SubstringJSC#
- Swift 中的 String 和 Substring 如何工作Swift
- JavaScript 中substr與 substring 的區別JavaScript
- JavaScript substring()JavaScript
- Substring with Concatenation of All Words
- SQL Server SUBSTRING FunctionsSQLServerFunction
- Js中substr,substring,slice擷取字串的異同JS字串
- mysql中substring_index類似split分組功能MySqlIndex
- MySQl 擷取函式 left(),right(),substring(),substring_index() 的用法MySql函式Index
- LeetCode 5 (Longest Palindromic Substring)LeetCode
- substr()和substring()區別
- SUBSTRING() 與 CONV() 函式函式
- ABC347B Substring
- String 類的 substring () 方法
- javascript中string物件方法中的slice、substring、substr的區別聯絡JavaScript物件
- Leetcode 30 Substring with Concatenation of All WordsLeetCode
- mysql 函式substring_index()MySql函式Index
- D. Non-Palindromic Substring
- [C#]C#中字串的操作C#字串
- Leetcode 3 Longest Substring Without Repeating CharactersLeetCode
- #3 Longest Substring Without Repeating Characters[M]
- CF163A Substring and Subsequence 題解
- Java基礎系列-substring的原理Java
- 【mysql】SUBSTRING_INDEX 用法舉例MySqlIndex
- SQL Server資料庫中Substring函式的用法例項詳解SQLServer資料庫函式
- Leetcode 3. Longest Substring Without Repeating CharactersLeetCode
- [LeetCode] 2414. Length of the Longest Alphabetical Continuous SubstringLeetCodeAlphabet
- Solution - Atcoder ABC280Ex Substring Sort
- [LeetCode] 3090. Maximum Length Substring With Two OccurrencesLeetCode
- CF1234F Yet Another Substring Reverse
- C#中的MVCC#MVC
- C#中的MVVMC#MVVM
- c#中的事件C#事件
- C#中的集合C#
- 吐槽Javascript系列一:slice()、substr()和 substring()JavaScript
- Leetcode javascript 3 longest-substring-without-repeating-charactersLeetCodeJavaScript
- [leetcode] 1624. Largest Substring Between Two Equal CharactersLeetCode