i am trying to replace each column values which contain 1's in an array with alphabets using c#, doesn't seem to work -


my array looks this:

c1 c2 c3 c4 0  1  0  0 1  0  1  0 1  0  0  1 0  0  1  1 0  1  0  1 

so in above need replace c1 column values a, c2 column values b, c3 column values c code have used still displays entire file changes not being implemented:

        var lines = file.readalllines(@"d:\as.csv");         (var = 1; < lines.length; i++)         {             var linesplit = lines[i].split(new[] { ' ' }, stringsplitoptions.removeemptyentries);             linesplit[0] = linesplit[0].equals("1") ? "a" : linesplit[0];              linesplit[1] = linesplit[1].equals("1") ? "b" : linesplit[1];             linesplit[2] = linesplit[2].equals("1") ? "c" : linesplit[2];             console.writeline(linesplit[0]);         }         console.readline();                           

this can you.

        foreach (var item in list)         {             item.c1 = item.c1.equals("1") ? "a" : item.c1;             item.c2 = item.c2.equals("1") ? "b" : item.c2;             item.c3 = item.c3.equals("1") ? "c" : item.c3;               item.c4 = item.c4.equals("1") ? "d" : item.c4;           } 

hope understand problem.


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -