I"m developing a simple application that have a line like this:
string[] values = ReadAll(inputFile);
As inputFile is a string, but how I can do this without conflicts(Cannot implicitly convert type 'string' in 'string[]')?
I"m developing a simple application that have a line like this:
string[] values = ReadAll(inputFile);
As inputFile is a string, but how I can do this without conflicts(Cannot implicitly convert type 'string' in 'string[]')?
Based on the exception message you gave us, ReadAll(inputFile)
returns a string
, and you assign it to a string[]
, so that's why it doesn't work.
This would work:
string input = ReadAll(inputFile);
After this do you want to split the strings in some way? We'd need more details to help you further.
Assuming your
ReadAll
method has a signature like thisthen the problem is not with
inputFile
but with the return value of the method which cannot be assigned to astring[]
.Are you maybe looking for File.ReadAllLines?
Or do you want to split a string by some delimeter?