In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the knowledge of "how to get the number of Chinese characters in a string by C # in asp.net". In the operation of actual cases, many people will encounter such a dilemma. Next, 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!
Strings can include numbers, letters, Chinese characters or other characters. The IsDigit static method of the Char type can be used to determine whether the characters in the string are numeric, and the IsLetter static method of the Char type can be used to determine whether the characters in the string are letters. Let's implement a method to judge whether there are Chinese characters in the string. Through this method, we can calculate the number of Chinese characters in the string. The running effect is as follows:
First of all, set the interface and content of Form according to the effect picture, Box1.Text is the input string, we deal with the string to calculate the number of Chinese characters, double-click the Buton control to edit its click event code.
We look at the Unicode range of Chinese characters and generally give the range from 0x4E00 to 0x9FA5. As long as the hexadecimal code of the character we receive is in this range, we think that this character is a Chinese character (the number of Chinese characters displayed by label4.Text).
The copy code is as follows:
String a=Box1.Text
Int K = 0
For (int I = 0; I
< a.Length;i++ ) { char j=a[i]; ushort s = j; if (s >= 0x4E00&&s
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.