|
-
April 1st, 2005, 08:09 AM
#3
Re: Converting a string into an integer array
 Originally Posted by ironman
I have input a string and I want to convert each element into an integer and store it individually in an array.For instance I input 123 as a string,i want to store it in array nums.The first index(nums[0]) should have 1 the second(nums[1])should have 2 and so on.Now here is what i`ve done(which is not working):
Code:
str=Console.ReadLine();
for(int 1=0;i<3;i++)
{
nums[i]=int.Parse(str[i]);
}
;
The error is that it cannot convert the first argument form a char to a string and ther are some invalid arguments.
I`m perplexed,anyone???
...1=0... is the culprit
I guess you wanted to write i=0. right ?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|