-
June 7th, 2014, 04:24 AM
#1
Cannot implicitly convert type 'string' to 'string[]'
Hello!
I have a rich text Box field named "txtReadfile" in which i load ea text file having possibly many word.
now i want to store the text from "txtReadfile" in a string array for further process, but when i try to do so by using the following code it give me an error "Cannot implicitly convert type 'string' to 'string[]' "
string[] arrTxtReadfile = txtReadfile.Text.ToString();
Please Help. thanks in Advance
-
June 7th, 2014, 12:45 PM
#2
Re: Cannot implicitly convert type 'string' to 'string[]'
A string and a string array are two different things.
When you call .ToString() on an object, it creates a [single] string, not a string array.
To fix declare string[] arrTxtReadFile without the [].
-
June 8th, 2014, 08:47 PM
#3
Re: Cannot implicitly convert type 'string' to 'string[]'
Originally Posted by Wahab_Phd
Hello!
now i want to store the text from "txtReadfile" in a string array for further process
If I get what you are trying to do, you want to store multiple strings for further process?
I believe you should use a List<string>, a Stack<string> or a Queue<string>. This way, you can store multiple strings without having to redimension an everytime.
Hope this helps!
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
|