c# - Remove character in all strings in a string array -


i'm developing c# .net framework library.

if have array string[] elements. , want remove character \" in of them, how can in 1 instruction?

i know can this:

foreach(string element in elements)    element = element.replace("\"", string.empty); 

is there way in 1 sentence? (without using foreach).

you can create new array new values:

var newvalues = elements.select(x => x.replace("\"", string.empty)).toarray(); 

if creating new array problem should stick loop approach.

in addition can't change foreach loop variable that.you should compiler error:

cannot assign 'element' because 'foreach iteration variable'

you need for loop:

for(int = 0; < elements.length; i++)     elements[i] = elements[i].replace("\"", string.empty); 

Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -