开发者

Sum of characters in textbox [closed]

开发者 https://www.devze.com 2023-03-08 07:13 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 10 years ago.

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:

Sum of characters in textbox [closed]


var text = "Abc";
text = text.ToUpper();
var sum = 0;
foreach (char c in text)
{
    sum += c - 64;
}

sum has your value.

0

精彩评论

暂无评论...
验证码 换一张
取 消