简体   繁体   中英

Count the characters in a cookie string using c#

Count the characters in a cookie string using c#

I have a string as follows:

string str1 = Request.Cookies["GE"].Value;

This string could be:

string str1 = "A";

or

string str1 = "AA";

or

string str1 = "AABB";

Using C#, I need to display the count of character as follows:

string str1 = "A"; ===> One
string str1 = "AA"; ===> Two
string str1 = "AABB"; ===> Four

Thanks in advance.

If you want an integer value use

Request.Cookies["GE"].Value.Length

If you need the value in words then make reference to the link provided by Bat_Programmer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM