当我们输入字母表时,我应该得到它的数字 [英] When We Enter Alphabet I Should Get It's Number
本文介绍了当我们输入字母表时,我应该得到它的数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的任务是当我输入字母表时我应该得到数字
例如:我输入D然后它应该显示4这是我的任务可以任何人帮助我
my task is when i enter the alphabet i should get the number
for e.g: I Entered "D" then It should show the "4" this is my task can any one help to me
推荐答案
嗯......你有没有考虑过称为减法的复杂数学运算?
尝试:
Um...have you ever considered the complicated maths operation called "subtraction"?
Try:
string inp = "ABCD";
foreach (char c in inp.ToUpper())
{
if (c >= 'A' && c <= 'Z')
{
Console.WriteLine("The \"number\" of '{0}' is {1}", c, c - 'A' + 1);
}
}
这篇关于当我们输入字母表时,我应该得到它的数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文