Tag: .Net

How-to: Converting Command Line String to ARGS

Converting Command Line String to ARGS Walk-through In testing a command line I recently wanted to verify that the string passed on the command line was converted to the args[]` array that was passed to `Main(string[] args).  For example, given the command line Compress.exe /v:ReallyMakeItSmall myfile.txt "Read ME.txt" What does the call to Main(string args[]) […]

Beware of Inequalities With Floating Point Types

Inaccuracies of Floats I have been playing around with the inaccuracies of floats and decided to share some of the simplest comparisons that might surprise folks that use the equality comparisons of floats indiscriminately. The following code listing pretty much captures the issues: using System.Diagnostics; … decimal decimalNumber = 4.2M; double doubleNumber1 = 0.1F * […]

Declaring Generic Interfaces With C#

C# Generics Implementation With the C# generics implementation that is currently under proposal it will be possible to declare generic interfaces, not just generic classes.  This is really cool as it avoids the ambiguity associated with returning an object such as in the System.Collections.IEnumerable interface.  In place of the non-generic interface we would use the generic System.Collections.Generics.IEnumerable […]

Using @ to Disambiguate Keywords from Identifiers in C#

C# Language Specification While reading the C# Language Specification today I noticed the use of the @ sign to disambiguate a keyword from an identifier.  When you do this the identifier is called a verbatim identifier.  So, for example, you could write code as follows: class @class { static void Main() { @static(false); } public […]