static void Main(string[] args)
{
countValues();
}
static void countValues()
{
float value1;
float value2;
float result;
Console.WriteLine("Give a number");
value1 = Convert.ToSingle(Console.Read());
Console.WriteLine("Give another number");
value2 = Convert.ToSingle(Console.Read());
result = value1 + value2;
Console.WriteLine("You gave numbers " + value1 + " and " + value2);
Console.WriteLine("Together these values are " + result);
Console.Read();
}
Run Code Online (Sandbox Code Playgroud)
有人能告诉我这段代码有什么问题吗?我上次使用C#已经很久了,我已经忘记了它的一切.当我运行这段代码时,它会询问一个数字.当我输入一些数字时,它会打印所有内容,而不会要求第二个.
我刚开始使用javascript和jquery,现在我遇到了这样的问题:
var myCharacter = ('#myCharacter').css('top'); // gives 140px
var numberOnly = myCharacter.replace('px',''); // gives 140
var total = numberOnly + 20; // gives 14020 not 160
Run Code Online (Sandbox Code Playgroud)
我只是不明白为什么会这样.