c# - Rewriting a Value in a For Loop -


[ resovled. again! dunno why loops trip me up, haha. ]

yet loop question. think going calling card. time, i'm working c#. trying figure out way phrase this, base code:

string[] daftchildren = new string[] { "deidra", "jolie", "johnna",                                         "kayben", "saber", "adam" };  (int = 0; < daftchildren.length; ++) {     console.writeline(daftchildren[i] + " member of family.");     if (daftchildren[i] == "saber") {         console.write("saber part of family... now.");     } } 

the code self explanatory: i'm using for loop list each member of family. if 1 of family members listed saber, prints "saber part of family... now." here's rub.

with above code, output print "saber part of family" , "saber part of family... now." how write only if block prints.

i hope asked enough. in advance!

a sneaky way it:

string[] daftchildren = new string[] { "deidra", "jolie", "johnna", "kayben", "saber", "adam" };      (int = 0; < daftchildren.length; ++) {         console.write(daftchildren[i] + " member of family.");         if (daftchildren[i] == "saber") {             console.write(".. now.");         }         console.writeline(); 

Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -