C# "cannot assign field because it is a foreach iteration variable" -
I want to trim the column header of a CSV file, the field below is an array containing the header names, where I Place trim ()? I put it with foreach loop, but VS Tells me that "this area can not be allocated as it is an agar walking variable". What am i doing
while ((fields = csv.GetCSVLine ()) = zero) {if (header) {foreach (fields in field) {// field = field.trim (); // VS: "Can not set the field because it is a predetermined variable" headers.Add (field); }}
You can do it on the same line as Add ( )
Add directly to
trim ()
call.
If you do not need to overwrite thefield
, theforeach (Field Fields) {Header. Add (field.Trim ()); }
Comments
Post a Comment