-1

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.

Kamil Budziewski
  • 22,699
  • 14
  • 85
  • 105
Hamamelis
  • 1,983
  • 8
  • 27
  • 41
  • 3
    Please check below link of possible answer [http://stackoverflow.com/questions/2729752/converting-numbers-in-to-words-c-sharp][1] [1]: http://stackoverflow.com/questions/2729752/converting-numbers-in-to-words-c-sharp – Bat_Programmer Apr 04 '14 at 10:34
  • Are you looking for the verbal representation as [Bat_Programmer](http://stackoverflow.com/users/475709/) suggested or just [`string.Length`](http://msdn.microsoft.com/en-us/library/system.string.length.aspx)? – default Apr 04 '14 at 10:46

1 Answers1

0

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.

Community
  • 1
  • 1
Colin Banbury
  • 857
  • 10
  • 17