Sum of characters in textbox [closed]
I'm tasked with building a program that performs math based on letters. Every let开发者_运维问答ter has one value. For example, A=1
, B=2
and C=3
. The user will enter a series of letters in a text box. If the user enters ABC
, the result would be 6
.
How do I perform this math?
Here is a picture of the user interface I have built:
var text = "Abc";
text = text.ToUpper();
var sum = 0;
foreach (char c in text)
{
sum += c - 64;
}
sum
has your value.
精彩评论