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
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 [].
Re: Cannot implicitly convert type 'string' to 'string[]'
Quote:
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!