What's the C# equivalent of Java's "for (String currLine: allLines)"? -



What's the C# equivalent of Java's "for (String currLine: allLines)"? -

i've got java code along lines of:

vector<string> alllines = new vector<string>(); alllines.add("line 1"); alllines.add("line 2"); alllines.add("line 3"); (string currline: alllines) { ... }

basically, reads big file lines vector processes 1 @ time (i bring in memory since i'm doing multi-pass compiler).

what's equivalent way of doing c#? i'm assuming here won't need revert using index variable.

actually, clarify, i'm asking equivalent of whole code block above, not just for loop.

list<string> can accessed index , resizes automatically vector.

so:

list<string> alllines = new list<string>(); alllines.add("line 1"); alllines.add("line 2"); alllines.add("line 3"); foreach (string currline in alllines) { ... }

c# java for-loop equivalent

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -