问题描述
我有这个:
I have this:
for(i=1; i<= num; i++)
{
loadNotes(resultado[i],resultado[i+num],pos_x,pos_y);
pos_x = pos_x+200;
//pos_y = pos_y+250;
pos_y = 0;
}
}
问题是:"i + num"不被视为SUM而是concat(.).
即,假设num = 5且对于i = 1
相反,resultado [i + num] = resultado [6]其发生的resultado [15].
num和resultado []是C#的字符串和字符串数组,我真的需要这种方式,所以我想知道如何解决此问题.
我无法解析整个数组,因为其中一半确实是字符串
The problem is: "i+num" are not being seen as a SUM but as a concat (.).
i.e., lets suppose that num = 5 and for i=1
instead resultado[i+num] = resultado [6] its happening resultado[15].
num and resultado[], are string and array of strings, comes from C#, I really need that way, so I''m wondering how can I solve this problem.
I cant parse the whole array because half of it are really strings
推荐答案
loadNotes(parseInt(resultado[i]),parseInt(resultado[parseInt(i)+parseInt(num)])),pos_x,pos_y);
祝您好运!
Good luck!
var mySum = parseInt(i) + parseInt(num)
loadNotes(resultado[i],resultado[mySum],pos_x,pos_y);
让javascript理解这些是数字是唯一要了解的,您想要对它们执行数学运算.
Having javascript understand that these are numbers is the only it''s going to understand you want to perform a mathmatical operation on them.
这篇关于变量和SUM的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!