Compiler Hints

When compiling code, the C compiler must be able to locate information about the components that are being used. It will automatically search the file named mscorlib.dll , which contains the lowest-level .NET entities, such as data types. To use other components, the appropriate .dll for that component must be specified on the command line. For example, to use WinForms, the system.winforms.dll file must be specified as follows csc r system.winforms.dll myfile.cs The usual naming convention is...

Indexing with an Integer Index

A class that contains a database row might implement an indexer to access the columns in the row public DataValue string name, object data row.Add new DataValue Id, 5551212 row.Add new DataValue Name, Fred row.Add new DataValue Salary, 2355.23m DataRow row new DataRow row.Load DataValue val DataValue row 0 Console.WriteLine Column 0 0 , val.Data val.Data 12 set the ID The DataRow class has functions to load in a row of data, functions to save the data, and an indexer function to provide access...

Mark and Compact

The .NET garbage collector uses a Mark and Compact algorithm. When a collection is performed, the garbage collector starts at root objects including globals, statics, locals, and CPU registers , and finds all the objects that are referenced from those root objects. This collection of objects denotes the objects that are in use at the time of the collection, and therefore all other objects in the system are no longer needed. To finish the collection process, all the referenced objects are copied...

Finding Members

This example will list the members of a type. public int DoThatThing int i, Decimal d, string args public int value 0 public float log 1.0f public static int value2 44 public static void Main String args Get the names and values in the enum Console.WriteLine Fields of MyEnum Type t typeof MyEnum create an instance of the enum object en Activator.Createlnstance t foreach Fieldlnfo f in t.GetFields BindingFlags.LookupAll object o f.GetValue en Console.WriteLine 0 1 , f, o Now iterate through the...

Eric Gunnerson

Eric Gunnerson

Release Team oR 2GG1 x Programming by Eric Gunnerson ISBN 1893115 This book takes the C programmer through the all the details from basic to advanced-- of the new Microsoft C - language. Written as an introduction to the new C , this guide takes the experienced C programmer a few steps beyond the basics. It covers objects, data types, and flow control, and even delves into some background on the new Microsoft NET Frameworks environment. Keeping in mind that this is for those familiar with C and...