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.
2.7 Summary<br />
The base types include<br />
• char<br />
• string<br />
• int<br />
• double<br />
The Framework Class Library includes many other classes such as<br />
• DateTime<br />
• StreamReader<br />
• HashTable<br />
• Object<br />
Variable declaration<br />
• Variable may be declared with different scope.<br />
• A typical declaration includes the type or class name followed by the variable<br />
name.<br />
• The declaration may include an initial value.<br />
• Constants may be declared in a similar way ‐ the modifier const precedes the<br />
type.<br />
duction <strong>to</strong> .NET<br />
<strong>Intro</strong><br />
Strings<br />
• Strings literals have double quotes.<br />
• Normally \ introduces codes ‐ for example \n and \t for new line and tab. For<br />
file names we must escape the backslash ʺc:\\dir\\file.txtʺ<br />
• A string literal preceded by @ prevents the backslash escape mechanism. We<br />
can have line breaks in strings. File names may be simpler @ʺc:\dir\file.txtʺ<br />
Converting <strong>to</strong> a string<br />
• We may use String.Format<br />
• We may use .ToString()<br />
• Format codes may be used <strong>to</strong> dictate the way values are rendered.<br />
Agilent .NET Course: C# Basics 7