haishSee haishSee - 4 years ago 135
C# Question

count all the characters I have used in a textbox c#

I want to calculate all the number of characters I have used in a textbox.
For example: If I write this equation in textbox:
so what code or line should I write for counting all the parenthesis used here?

Answer Source

var strEquation=textbox1.Text; //5x-2(3y+2)*3y(8)

int x = strEquation.Count(c => Char.IsNumber(c)); // 6
int y = strEquation.Count(c => Char.IsLetter(c)); // 3

int total=x+y;

Let me know if it works?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download