hey...i want to ask about how to convert string array to integer array. hope someone can help me.
thanks.

Recommended Answers

All 2 Replies

int[] StringToInt(String[] input) {
    int[] output = new int[input.Length];

    for (int i = 0; i < input.Length; i++) {
        output[i] = Int32.Parse(input[i]);
    }

    return output;
}

There is no error checking in this code. Passing a null array or anything in the string array that isn't an integer will throw an exception.

hey...i want to ask about how to convert string array to integer array. hope someone can help me.
thanks.

As long as the strings are only numbers (no commas or dots indside the string), you can convert the string into integer as Momerath shows abouve.
Mitja

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.