Archives for the 'C#' Category
By value, by reference: by analogy
Here’s my best attempt to explain C# value types and reference types, and “pass by value” and “pass by reference” to a newbie. (Not you, of course.)
Value types
A piece of paper, on which is written the number 5. You use this number to calculate something.
Reference types
A piece of paper, on which is written a memory […]
Data Sanitizer
I wrote a C# console app to sanitize CSV files. It replaces numbers with X’s so that social security number 123456 becomes XXXXXX and the address “49 Main St” becomes “XX Main St”. Both the input and the output are streamed to ensure that the program won’t run out of memory even with arbitrarily large […]
Snippet Compiler
This is one programming tool I wish I had discovered from the very beginning: Snippet Compiler. It allows you to test out C# code without having to fire up Visual Studio and laboriously create test console applications etc.
Although the latest version (3.0.2 for .NET 3.5) is an alpha, it seems very polished and I have […]
Bug in SgmlReader
Update 20 April 2010
SgmlReader 1.8.6 has this problem fixed.
Original post
Chris Lovett of Microsoft wrote SgmlReader 1.7 and has kindly shared it with the world. What does it do? In his own words:
An XmlReader implementation for loading SGML (including HTML) converting it to well formed XML, by adding missing quotes, empty attribute values, ignoring duplicate attributes, […]
C# Hidden Danger #2: GetHashCode()
Suppose you have an address book saved as a CSV text file or an XML file. You would like to create a program that loads the address book into memory, and return the contact details of a person, given the name.
There are a number of data structures from which to choose: array, ArrayList, List<T>, Hashtable, […]
