C Programming Tutorials and advice
CProgrammingTrends News Archives About Us Feedback

Recent Articles

Assigining a TypeConverter to a Class you Don't Own
I ran into problems with the XNA Beta1, where by I had a class that had a Vector2 struct in.

Rational Betas Have C++ Goodies
Features in the Rational Software Architect v7.0 beta include improved support for C++, and developers can...

Revisiting C/C++ On Eclipse
The tutorial from IBM's developerWorks on using the C/C++ Development Toolkit (CDT) for Eclipse received a refresh over the summer, and it merits a look from those who may have missed it since then.

Using Immediate Window to Work with Values
This article is an excerpt from the book: Murach's ASP.NET 2.0 Web Programming with C# 2005.

C++ - No Fears And Great Books
This is a quick look at a couple of stories on C++, namely why programmers should not feel The Fear of native code, and a quintet of books that should occupy the...

New NetBeans Pack Supports C/C++
Developers who work in C or C++ can use the NetBeans integrated developer environment to build applications...


11.02.06


Creating Safe Events In C#


By Mads Kristensen

Whenever you write class libraries, custom control or just about anything else, you probably raise a lot of home made events. That's a simple thing to do, but tedious to write over and over again.

That's why I always use this snippet for Visual Studio 2005 that writes the whole thing for me. Download the snippet and place it in the Visual Studio snippet folder which is placed at My documents\Visual Studio 2005\Code Snippets\Visual C#\My Code Snippets\.

Just fill out the name of the event and the EventArgs type that by default is EventArgs. It will then write the XML comment and a method that raises the event in a safe manor. That method is given the same name as the event, but prefixed "On". So, if you create an event called Saved, the method that raises the event is called OnSaved.

This is what happens when you type evnt and hit TAB twice.



And after you've filled out the type of EventArgs and named the event Saved, this will be the result:

Low Rate eCommerce & Retail Plans



This saves me for typing the same stuff over and over again.

For more snippets, visit Vault of Thoughts who has some nice ones.

Comments

About the Author:
Mads Kristensen currently works as a Senior Developer at Traceworks located in Copenhagen, Denmark. Mads graduated from Copenhagen Technical Academy with a multimedia degree in 2003, but has been a professional developer since 2000. His main focus is on ASP.NET but is responsible for Winforms, Windows- and web services in his daily work as well. A true .NET developer with great passion for the simple solution.

About CProgrammingTrends
A collection of articles and tutorials designed to help C and C variant programmers in their programming work. C Programming Tutorials and advice

CProgrammingTrends is brought to you by:

SecurityConfig.com NetworkingFiles.com
NetworkNewz.com WebProASP.com
DatabaseProNews.com SQLProNews.com
ITcertificationNews.com SysAdminNews.com
LinuxProNews.com WirelessProNews.com
CProgrammingTrends.com ITmanagmentNews.com


-- CProgrammingTrends is an iEntry, Inc. publication --
iEntry, Inc. 2549 Richmond Rd. Lexington KY, 40509
2006 iEntry, Inc.  All Rights Reserved  Privacy Policy  Legal


archives | advertising info | news headlines | free newsletters | comments/feedback | submit article




CProgrammingTrends Home Page About Article Archive News Downloads WebProWorld Forums Jayde iEntry Advertise Contact