In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you how to use the string in C#, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!
1.C# string segmentation
String url = "http://asdfsfd asdf asdfsdf"; string [] sss = GetString (url, "); foreach (string strin sss) {Response.Write (str.ToString () +");} private string [] GetString (string str,string cutStr) {char [] cutChar = cutStr.ToCharArray (); string [] sArray = str.Split (cutChar); return sArray;}
2.C# string interception
Public static string GetFirstString (string stringToSub, int length) {Regex regex = new Regex ("[\ u4e00 -\ u9fa5] +", RegexOptions.Compiled); char [] stringChar = stringToSub.ToCharArray (); StringBuilder sb = new StringBuilder (); int nLength = 0; bool isCut=false; for (int I = 0; I)
< stringChar.Length; i++) { if (regex.IsMatch((stringChar[i]).ToString())) { sb.Append(stringChar[i]); nLength += 2; } else { sb.Append(stringChar[i]); nLengthnLength = nLength + 1; } if (nLength >Length) {isCut=true; break;}} if (isCut) return sb.ToString () + "..."; else return sb.ToString ();}
3. Take the substring function SubString
String tmp2 = tmp1.SubString (0jue 3); equivalent to mid tring str= "abcdefg" in vb.net; string strstr1=str.Substring (2pr 3); / / str1= "cde"
What function in 4.C# can tell if there is a character in a C # string? For example, does "akkk*kkk" have "*"?
String s = "akkk*kkk"; int I = s.IndexOf ("*"); if (I! =-1) contains else but not else
5. Align the characters in this instance to the right and fill them with the specified Unicode characters on the left to reach the specified total length.
Public string PadLeft (int, char); str = "256"; strstr = str.PadLeft (5," 0 "); / / str =" 00256 "is all the content of this article" how to use strings in C# ". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.