CodePudding user response:
For homework?String into a Char array, converted to ASCII, on a (97) + 1 score,
There is a way to use a dictionary Dict the table, and then, in turn, values
CodePudding user response:
First of all, to construct a set of 1 a, 2 b.
Var ar=Enumerable. Range (65, 26).
Select (d=& gt; ASCIIEncoding. ASCII. Get string (new byte [] {} (byte) d)).
Select ((d (I)=& gt; New {I=I + 1, d}) ToList ();
Then according to the input string dismantling sum.
Var STR="ABC".
Var strar=STR. ToCharArray (). The Select (d=& gt; Which oString (). The ToUpper ()). ToList ();
Var store=0;
The foreach (var item in strar)
{
Store +=ar. FirstOrDefault (d=& gt; D.d==item). I;
}
Console. WriteLine (${store "} ");
As to the problem of accumulation is a cycle to receive... Done by oneself
CodePudding user response:
The enumeration, and then divide each enumeration value accumulation of the characters.