C# Sample Code
-
Databinding SqlTypes
by Dan Glass
Demonstrates how Databind the SqlTypes using the PropertyDescriptor class and the ITypedList Interface.
-
Using the NotifyIcon control
by Colin Harman MACITP
This short article describes how to use the NotifyIcon in your applications and how to add menus to the icon.
-
A Chat Client/Server Program for C#
by Michael H
Source code for a chat server, and the accompanying client program.
-
Calculate Age
by James Crowley
How to calculate someone's age from their birth date.
-
Custom Word Wrapper
by David Cumps
A nice little class that takes some text, and will automatically wrap it according to a specified width.
-
Capture a Screen Shot
by James Crowley
Demonstrates how to capture a screen shot of the entire desktop, or a particular window in C# or VB.NET.
-
Add a JavaScript popup to an ASP.NET button
by Edward Tanguay
How to add a javascript popup (alert) question to an ASP.NET button control.
-
Complex Data Binding
by Dan Glass
Complex Data Binding a collection implementing IBindingList and ITypedList
-
C# String Functions and Manipulation
by Colin Harman MACITP
Learn how to manipulate C# strings using built-in and custom functions. The code provided shows how to trim, find, search, replace and split strings, convert to upper case and proper case and more.
-
How to create PDF files from ASP.NET pages
by Edward Tanguay
How to create PDF files from ASP.NET pages with Crystal Reports without using Visual Studio.NET
-
Sorting and Searching Using C# Lists
by Craig Murphy
The support for lists in C# 2.0 makes sorting and searching very easy. This code snippet demonstrates how to create a list of Person objects (with name and age attributes), sort by name, sort by age and search based on age.
-
Using ASHX files to retrieve DB images
by Harry Pierson
Learn how to use the little-known Http Handler functionality of ASP.NET to serve images from a database.
-
Using the Credential Management API
by Alan Dean
Following secure development best practice, an application should obtain and store user credentials securely. Microsoft has provided a means to accomplish this on the desktop: the unmanaged Credential Management API, which exposes the capability to provide a standard login experience for the user which is also secure. This code demonstrates how to create a generic dialog implementation using this API.
-
Save a Stream to a File
by James Crowley
Demonstrates how to write a stream to a file.
-
Listing Files & Folders in a directory
by Colin Harman MACITP
Retrieves all files and folders within a specified folder location, along with the file size and extension.
-
Pinging a host from VB .net
by MstrControl
A class that allows ping a computer.
-
Image to HTML
by Michael H
A simple program that converts images into blocks of font tag colored 1s and 0s.
-
How to display a date in a specific language
by Edward Tanguay
How to convert a date and display it in the correct format for a given language.
-
Convert an array to a comma-delimited string
by Edward Tanguay
How to convert an array into a comma-delimited string with String.Join
-
How to write an ASHX file
by Edward Tanguay
An example of using a web handler file which you can use when your output is not going to a browser but to an xml-consuming client of some kind, keeping you away from all the browser technology you don't need.