I am getting an error saying
Syntax error value expected.
In this code
public string[] TabAsDelimiter(string strValue)
{
string data = strValue;
string[] words = data.Split('\t');
foreach (string word in words)
{
return word[];
}
}
returns the values in the array
word[]
is wrong. If you want make word
an array, you could use word.ToCharArray()
, but it would result in char[]
, not string[]
.
But I really doubt that you want to return char array. Moreover, you would return only character array of the first word! Because method finishes as soon as it reaches return
statement.
I think you just want to return array of words split by tab. In this case, your method should look like:
public string[] TabAsDelimiter(string strValue)
{
if(string.IsNullOrEmpty(strValue)) return null;
return strValue.Split('\t');
}
try
return data.Split('\t');
After Split you got an array.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.