![](/img/trans.png)
[英]How can I check if a letter in a string is uppercase using the power of TypeScript?
[英]Check string contents using index for Uppercase
我想檢查一個字符串是否總共包含31個字符,索引0,1,30是否為大寫。 例如:
string MyTestString = "INbwzfnpdmcwqq1dl22mcsdeycet2dD";
If (MyTestString.Contains(31 characters and index 0,1,30 are uppercase))
{
// proceed with rest of program
}
if (MyTestString.Length ==31 && Char.IsUpper(MyTestString[0]) && Char.IsUpper(MyTestString[1]) && Char.IsUpper(MyTestString[30]))
{
}
if (str.Length == 31 && new []{ str[0], str[1], str[30] }.All(char.IsUpper))
31個字符,索引1,2,31為大寫
如果你有lenght的字符串31
,則最后一個索引是30,因為基於陣列的索引是零,因此開始從0
到length - 1
。從規格 :
對於長度為N的維,索引的范圍可以從0到N – 1(含)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.