In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the relevant knowledge of "what are the methods of intercepting strings in C#". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
First: intercept with split based on a single delimited character
Cash disk website production Q
String st= "GT123_1"
String [] sArray=st.split ("_")
/ / you can get sArray [0] = "GT123", sArray [1] = "1"
The second: using multiple characters to separate strings
String str = "GTAZB_JiangjBen_123"
String [] sArray = str.Split (new char [2] {'jacks,' _'})
Foreach (string e in sArray)
{
Console.WriteLine (e)
}
/ / get sArray [0] = "GTAZB", sArray [1] = "Jiang", sArray [2] = "Ben", sArray [3] = "123"
Third: intercept strings according to strings or string groups
Copy the code
String str = "GTAZB_JiangjBen_123"
String [] sArray = str.Split (new string [] {"Ji", "jB"}, StringSplitOptions.RemoveEmptyEntries)
Foreach (string e in sArray)
{
Console.WriteLine (e)
}
/ / get sArray [0] = "GTAZB_", sArray [1] = "ang", sArray [2] = "en_123"
This is the end of the content of "what are the methods of intercepting strings in C#". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.