how to skip writing the value to the file if it = 0 in my calculator program
Procedure that writes the array into a file
public void SaveArrayToFile()
{
int count;
var writer = new System.IO.StreamWriter("C:/calc/calculations.txt",false);
for (count = 0; count <= Results.Length -1 ; count++)
{
if (Results[count] == 0)
{
// problem
}
writer.Write(Results[count]);
writer.WriteLine();
}
writer.Dispose();
Any help would be valued
else, if your loop has a large bodycontinues will make it unreadableResults[count] == 0? Should it write an empty row to the file? Should it write a special value that means 'no data present'? Should it skip the row entirely? Skipping the row entirely is easy with thecontinuekeyword, but if these results need to be read in by another program, that may not work.writer.Dispose();in the end, you should use ausingstatement:using (var writer = new StreamWriter("C:/calc/calculations.txt", false)) { for ... }.