C#: creating objects, new keyword

You can’t allocate classes on the stack in C#, unlike C++.

The new keyword calculates the number of bytes needed for the specified object and allocates enough memory from the managed heap.

C# object variables are a reference to the object in memory, not the object itself.

C#: System.Environment

Here are a few handy properties and methods that are found on the System.Environment class:

Current OS: System.Environment.OSVersion

Current working directory: System.Environment.CurrentDirectory

string[] of drives on the machine: System.Environment.GetLogicalDrives()

Version of .NET app is running under: System.Environment.Version

Current machine name: System.Environment.MachineName

Newline symbol for the current environment: System.Environment.NewLine

Number of processors on the current machine: System.Environment.ProcessorCount

Full path to system directory: System.Environment.SystemDirectory

User name application is running under: System.Environment.UserName

C#: Variations on the Main() method, System.Environment.GetCommandLineArgs()

Below are a few different variations that can be done on the Main method.

Return type is void, string array as argument:

Return type is void, no arguments:

Return type is int, no arguments:

Return type is int, string array as argument:

Besides accessing them via the ‘string[] args’ parameter, you can access command-line arguments using

When you do this, you are not required to define the Main() method as taking a string array.

.NET: csc.exe, cordbg.exe

csc.exe /target:winexe – prevents a console window from appearing in the background

cordbg.exe assemblyloads .pdb file

b: set or display breakpoints
del: remove one or more breakpoints
g: continue debugging
p: print all loaded variables
o: step out of the current function
si: step into the next line
so: step over the next line
ex: exit the debugger