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 the  field , the  foreach (Field Fields) {Header. Add (field.Trim ()); }  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -