C# Sample Code
-
How to delete records with SqlCommand
by Edward Tanguay
This code shows you how to delete records with an SQL statement and get the number of records deleted returned back as an integer.
-
Inserting images into Word documents using XML
by Jonathan Greensted
I've seen many, many requests on the Microsoft newsgroups asking how you can insert a picture into a Word document without saving it to the file system first. This example application described in this blog illustrates both methods for inserting a picture firstly using the Word object model (InlineShapes.AddPicture) and secondly using Word's XML support (InsertXML).
-
I need a time-out!
by Wouter van Vugt
I need a time-out! Or more specifically, my methods need a time-out mechanism. And because I spent seven projects and quite some time on the web trying to find out how to do it correctly, I am writing this small article about the works.
-
Executing a .CS file
by David Cumps
Demonstrates how to write a C# program that can "launch" a .cs file and execute it.
-
How to get an array of all files in a directory
by Edward Tanguay
This simple code will give you an array containing all files in a directory.
-
IE Browser Helper Objects
by Steven Cohn
A demonstration of how to implement an IE Browser Helper Object in C#
-
Reading Binary Data in C#
by Jon Skeet
How to read binary data from a file in C# - the right way!
-
The "Using" Statement in C#
by Xavier Larrea
The using statement in the c# language allows us to define an scope for an object lifetime. This statement obtains the resource specified, executes the statements and finally calls the Dispose() method of the object to clean it up.
-
Using Microsoft Agent in C#
by M M Harinath
Microsoft Agent is a new technology, which allows Programmer to create and use animated characters that can interact with end users. It also supports the Microsoft Speech API, which allows the character to speak with the user.
-
How to simulate a status bar in a Web application
by Edward Tanguay
If you have a process that takes over 20 seconds or so on a Web application, you may want to let the user know the status of the process. Edward shows you how.
-
Checking Internet Availability using C#
by M M Harinath
While developing Internet applications, this is important to check whether the internet connection is available or not. This snippet will be useful to achieve the above mentioned task.
-
Easy Asynchronous Programming
by Simon Soanes
A simple demonstration of how to use multithreading and delegates in .NET to execute a method that will take a long time, without locking up our main thread.
-
Data Entry Validation with Error Provider
by Colin Harman MACITP
This example code uses the errorProvider control which ships with c# to validate data entry and shows the error icon if validation is not correct
-
Sending Authenticated Emails in .NET 2.0
by Xavier Larrea
Learn what's changed with .NET 2.0 and how to send out emails using an SMTP server that requires authentication.
-
Applying XSL transformations to XML in .NET
by Krishnan
A simple demonstration of how to apply an XSL transformation to an XML file and save the output using .NET
-
A shell for Google's image search
by Michael H
A program that searches on Google's Image Search.
-
How to measure how long a task takes
by Edward Tanguay
If you want to compare the performance of two processes, you can use this code to measure and print out the time takes by each process
-
Simple Object Relation Mapping with Reflection
by Simon Soanes
This is some code I wrote a little while back as an example O/R mapper.
-
Windows Forms and the Idle Loop
by Mike Taulty
When you're writing Windows Forms applications it's always nice to be able to keep the UI responsive in order to avoid frustrating the user. Here's a method of completing your asynchronous work on the Application Idle loop rather than allowing another thread to wander into your Windows Forms code and then trying to deal with it by Control.Invoke.
-
C# WebCam Service with FTP and Installer
by Dan Glass
A C# WebCam Windows Service demonstrating FTP upload, Windows Service Installer, and file rotation.