简体   繁体   English

使用 c# 计算 cookie 字符串中的字符数

[英]Count the characters in a cookie string using c#

Count the characters in a cookie string using c#使用 c# 计算 cookie 字符串中的字符数

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:使用 C#,我需要按如下方式显示字符数:

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.如果您需要单词中的值,请参考 Bat_Programmer 提供的链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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