本文介绍了如何转换int数组为int?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想学习如何做的是一个int数组转换为int在C#。
What I would like to learn how to do is to convert an int array to an int in C#.
不过,我要追加INT从数组中的值。
However I want to append the int with the values from the array.
例如:
int[] array = {5, 6, 2, 4};
将被转换成相当于5624一个int。
Would be converted into an int that equals 5624.
感谢提前任何帮助。
推荐答案
简单地乘以每个数与数组中的10 ^他的地方。
simply multiply each number with 10^ his place in the array.
int[] array = { 5, 6, 2, 4 };
int finalScore = 0;
for (int i = 0; i < array.Length; i++)
{
finalScore += array[i] * Convert.ToInt32(Math.Pow(10, array.Length-i-1));
}
这篇关于如何转换int数组为int?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!