03.01.2015 Views

C# 5.0 Programmer's Reference

Visual Studio 2013 C# 5.0 Programmer's Reference

Visual Studio 2013 C# 5.0 Programmer's Reference

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 18 ❘ 687<br />

}<br />

// Save the text.<br />

using (StreamWriter writer = File.CreateText("Notes.txt"))<br />

{<br />

writer.Write(notesTextBox.Text);<br />

}<br />

6. The IsFileSorted example program uses the following FileIsSorted method to determine<br />

whether a file’s contents are sorted.<br />

// Return true if the file's lines are sorted.<br />

// This method throws an exception if the file doesn't exist.<br />

private bool FileIsSorted(string filename)<br />

{<br />

// Open the file.<br />

using (StreamReader reader = new StreamReader(filename))<br />

{<br />

// Start with a line stopNumber) break;<br />

primesListBox.Items.Add(i);<br />

writer.Write(i.ToString() + " ");<br />

}<br />

}<br />

The code that defines the AllPrimes iterator is the same as in the earlier program, so it isn’t<br />

shown here. See the solution to Exercise 14-8 for that code.<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!