Having trouble understanding reading text files in C# -


so i'm in 1st year of college, c# in visual studio 1 of 6 modules.

basically problem is, need read in value that's in .txt file , calculate commission value.

the .txt file consists of:

1,pat ryan,280 2,mary smith,300 3,tom lynch,20 

the 3rd value on each line need calculate commission can't wrap head around getting value since can't pick out value code using, need go through each line next.

this is i've done far. tried doing calculations way:

if (columns [0] < 1000) {commission = column[0] * .05} 

but error:

"operator '<' cannot applied operands of type 'string[]' , 'int'"

any appreciated!

static void salesreport()  {     string path =  "sales.txt";     filestream fs = new filestream(path, filemode.open, fileaccess.read);      streamreader salesreport = new streamreader(fs);      string inputtext = salesreport.readline();      console.writeline("{0,-15}{1,-30}{2,-20}\n", "number","name","sales");      while (inputtext != null)     {         string[] columns = new string [3];          columns = inputtext.split(',');          console.writeline("{0,-15}{1,-30}{2,-10}\n", columns[0], columns[1], columns[2]);          inputtext = salesreport.readline();     } } 

you cannot perform comparison operation between string , int specified in error. need cast value text file int , comparison.

if (convert.toint32(columns[2]) < 1000)  {     commission = convert.toint32(columns[2]) / .05; } 

looks want 3rd column, have changed index 2.


Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -