C# Sample Code
-
How to convert a string to a date
by Edward Tanguay
Finding out how to convert one type to another in .NET is tricky. Here is the answer to converting a string to a DateTime type.
-
Making a .NET app run on Vista with Administrator priviledges
by James Crowley
If you're targeting Windows Vista and your application requires administrator priviledges (such as accessing the program files directory), then it will fail unless you include a manifest so Windows knows. Here's how.
-
Asynchronous HttpWebRequest
by Steven Cohn
Demonstrates how to build a much more responsive and user-friendly application by using asynchronous HttpWebRequests.
-
Adding controls to PlaceHolders dynamically
by Edward Tanguay
A simple example demonstrating how to dynamically add controls to a PlaceHolder control.
-
Merge an .exe and a .dll into one .exe
by Edward Tanguay
How to merge an .exe and a .dll into one .exe using ilmerge in VS.NET
-
How to check to make sure a URL is valid
by Edward Tanguay
A neat bit of code that checks if a domain is valid and actually exists.
-
Generate PDFs using C# and the free iTextSharp library
by James Crowley
Learn how to use the free iTextSharp library to load a PDF form, populate some dynamic fields, and then save out a flat PDF file.
-
User-Friendly Validation using ErrorProvider
by Tim Dawson
Data entry is a very important part of a lot of applications. It is important to validate data as it is entered without disturbing the user. Enter the ErrorProvider component.
-
Deep clone an object in .NET
by James Crowley
A simple code snippet that deep-copies an object by serializing and de-serializing using the BinaryFormatter
-
Read MP3 Tag Information (ID3v1 and ID3v2)
by Erin Jones
This sample source code demonstrates how to read IP3v1 and IP3v2 tag information from MP3's, along with MPEG headers too.
-
Create Controls At Runtime
by Colin Harman MACITP
Shows how to create controls at runtime and set their properties
-
Placing results from DataReader into an Array
by Edward Tanguay
Since a connection cannot be used until a DataReader has been closed, it is quite often necessary to read the results of a DataReader into an array, then close the DataReader, then you can process the data in the array while you use the connection for something else. This shows you how.
-
Validating an Integer
by Simon Soanes
How to validate an Integer the fast/efficient way in C# using Double.TryParse()
-
Generate an Image of a Web Page
by Alan Dean
Demonstrates how to fetch images and thumbnails of web pages using a hidden web browser control.
-
FTP client library for C#
by Dan Glass
An FTP client library for C#, including asynchronous operation
-
Create Hashes - MD5, SHA1, SHA256, SHA384, SHA512
by David Cumps
In PHP its a simple task to generate hashes, but in C# it takes a little more work. We'll create a Hash class to simplify the process.
-
How to access a MySQL database with .NET
by Edward Tanguay
Demonstrates how to connect to a MySQL database with C#.
-
Double buffering in .NET
by Simon Soanes
Ever wondered how to double buffer with a Graphics object so your GDI+ based game/control doesn't flicker annoyingly? Here's how!
-
Parse a UK Date String
by James Crowley
Ever wondered why DateTime.Parse doesn't recognise non-US date format? Here's how to get it to!
-
XML Node Insert
by Paul Parks
Someone recently asked on the Undernet #C# channel for help with inserting a block of XML into an existing XML document. After perusing a couple of MSDN articles here's what I came up with.