In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.