i have array of strings defined called currentrow. have loop looks this:
for (int index = 0; index < currentrow.length; index++) { if (currentrow[index] == string.empty) { currentrow[index] = null; } if (currentrow[index] == "''") { currentrow[index] = string.empty; } }
if linq query instead, like? better off using loop instead this? seems linq query have create multiple copies of array.
if linq query instead, like?
if want project new array (and optionally overwrite existing reference) like:
currentrow.select(r => r == string.empty ? null : r == "''" ? string.empty : r) .toarray();
if wanted use linq modify original collection evil lambda side-effects horrible utter in place.
am better off using loop instead this?
probably. avoid creation of new array.
it seems linq query have create multiple copies of array.
no, 1 additional copy. , if overwrite original reference (and if nothing else has reference it) garbage collected necessary.