Complete set: Intro to C - Bill Buchanan
Complete set: Intro to C - Bill Buchanan
Complete set: Intro to C - Bill Buchanan
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
5.5 Contributing <strong>to</strong> Intellisense<br />
We can comment our code so that out comments pop up in the intellisense pane.<br />
Examples of the definition of an overloaded method<br />
///<br />
///Increase the population of this country<br />
///<br />
///Number of new people<br />
public void IncPop(<br />
int increment)<br />
{<br />
this.population += increment;<br />
}<br />
Comments need <strong>to</strong> be in xml tags such as or .<br />
The tags must be in the triple stroke comments <strong>to</strong> be processed.<br />
The comments should immediately precede the declaration line.<br />
See the help section “Recommended Tags for Documentation Comments”.<br />
5.6 Exceptions<br />
duction <strong>to</strong> .NET<br />
<strong>Intro</strong><br />
C# uses exceptions <strong>to</strong> deal with run time errors.<br />
We protect areas of code that can possibly generate exceptions using a try block –<br />
we must add a catch block and we may add a finally block.<br />
Examples of Exceptions 3.2.1<br />
Console.WriteLine("Test started.");<br />
try<br />
{<br />
StreamReader fs = new StreamReader("c:\\nosuchfile.txt");<br />
Console.WriteLine("The file stream has been opened.");<br />
string s=fs.ReadLine();<br />
Console.WriteLine("A line of text has been read.");<br />
}<br />
catch<br />
{<br />
Console.WriteLine("An exception was raised.");<br />
}<br />
finally<br />
{<br />
Console.WriteLine("Finished.");<br />
}<br />
Console.WriteLine("Test completed.");<br />
Agilent .NET Course: Module 5, page 5