Text File IO

Certainly one important type of file is the text file, which consists entirely of lines of text separated by end-of-line markers. The System.IO namespace has specific classes to read and write text files. Here's the class hierarchy MarshalByRefObject TextReader (abstract) StreamReader StringReader TextWriter (abstract) StreamWriter StringWriter Although these classes are not descended from Stream, they certainly make use of the Stream class. The two classes I'm going to focus on here are...

First Program cs

FirstProgram.cs (c) 2006 by Charles Petzold Microsoft .NET Framework ) Let's first try to create, compile, and run this program, and then I'll discuss its structure and contents. Although you'll probably eventually use Microsoft Visual Studio to develop .NET programs, that's not your only option. You can actually edit, compile, and run .NET programs from the MS-DOS command line. In many respects, compiling a C program on the command line is quite similar to the way you might have compiled a C...

Decimal Data Type

C also defines a decimal data type that offers about 28 decimal digits of precision. The decimal is useful for storing and calculating numbers with a fixed number of decimal points, such as money and interest rates. In my book Programming in the Key of C , I deliberately covered decimal before floating point. I think it's important for new programmers to use decimal for most applications involving non-integral data types, particularly when the calculations involve money. The C and C++ languages...

Constructors

Consider this expression new Date What this expression actually does depends on whether Date is a structure or a class. If Date is a class, the new operator allocates memory from the heap sufficient to store an object of type Date. This memory must be sufficient for all the instance fields defined in the class. The memory allocation causes these fields to be set to zero, which causes all value-type fields to be set to zero, and all reference-type fields to be set to null. The new operator...

Why NET

The Microsoft .NET Framework which I'll often refer to with the simpler term .NET is a collection of software technologies that began emerging from Microsoft Corporation around the turn of the century. The first version of .NET was released early in 2002, and version 1.1 came out in 2003. Version 2.0 was released late in 2005, and Version 3.0 followed in late 2006. A good overview of the .NET releases can be found in the Wiki-pedia entry on the Microsoft .NET Framework http en.wikipedia.org...

Calendars Around the World

Four DateTime constructors have arguments of type Calendar, for example new DateTime year, month, day, cal The final argument is of type Calendar and indicates how the year, month, and day arguments are to be interpreted. Constructors without the Calendar argument are assumed to refer to dates in the Gregorian calendar. These other constructors allow the arguments to refer to dates in other calendars. Calendar is an abstract class defined in the System.Globalization namespace, which also...