DevLink 2010 Registration Open

Registration is OPEN for DEVLINK 2010

It's time to get your ticket for DEVLINK 2010.  The devLink Tecnical Conference has opened registration.  To purchase a ticket, simply go to, click on the Get My Ticket menu item at the top of the page and fill out the form, or click here to go directly to the Registration page.

While it’s still a few months away from the conference, tickets are already flying out the door.  Don't forget that we have limited seating and once registration closes, tickets will no longer be available.  At $100 for 3 great days of technical training, in-person networking, open spaces and lots of fun, DEVLINK 2010 is truly the best deal going!  That's less than $5 per hour for some of the most relevant and important training you can receive all year!

So, be sure to get your ticket before they're all gone and join us August 5 - 7, 2010 for DEVLINK 2010!

iPhone App Image

Announcing the DEVLINK iPhone App!

The iPhone store seemingly has an app for everything.  Need an app to calculate the tip for a group of 45 at a restaurant?  Yep, at least 100 apps for that.  Well now, there's an iPhone App for DEVLINK 2010!

The DEVLINK 2010 iPhone app brings everything you need to determine which sessions to attend, what speakers will be attending and what's going on at DEVLINK 2010 to your iPhone.  You can find out more about our great sponsors, check out the latest tweets about DEVLINK 2010 and even check out a map of Nashville to figure out what you want to do when you're not at DEVLINK!

The app was developed by John Baker for the conference, and thanks to John's generosity, you can get this app from the App Store for the amazing low price of... FREE!

More information about the app is available from John's website.


Session Details and Speaker Info Now On

Even if you don't have an iPhone, you can still get the lowdown on all sessions for DEVLINK 2010 at our web site.  The entire session list is color coded based on track, allowing you to find what you're most interested in and follow that track easily.  You can also filter the list down to show only the tracks, timeslots or speakers you are interested in.

Additionally, information about our great speakers is now available at the DEVLINK 2010 website.  Click on any of the speaker's faces to get more information about him/her, visit his/her web site and even check out his/her Twitter page.

Nwa VS2010 InstallFest Reminder

Visual Studio 2010 launches TODAY!!!! and to celebrate the we are having a Visual Studio 2010 Install Fest and Board Game Geekout on Saturday April 17, 2010.  That’s this weekend!!!! We will be playing all kinds of games including Xbox, PS3, Wii for console games and Settlers of Catan and D&D for board games. 

Event Information:

Date April 17, 2010
Time 11 AM to ???
Location Tyson Corporate Headquarters
22010 West Oaklawn Drive
Springdale, AR 72762
Rooms 126 &127




Venue Sponsor

Food Sponsor

There are currently 18 people that have decided to join us if you were waiting for the last minute this is it.  Get your ticket here!

Hope to see you there!

Enums: Learn to love them

So, I was dredging around in a some old code I inherited looking for that one magical place to make my new change when I came across a piece of code that, well, just made me laugh and then cry.

Here it is:

 1: switch (ddlRollupInterval.SelectedValue) 
 2: { 
 3:     case "Daily": 
 4:         r.RollupInterval = Report.Interval.Daily; 
 5:         break; 
 6:     case "Weekly": 
 7:         r.RollupInterval = Report.Interval.Weekly; 
 8:         break; 
 9:     case "Monthly": 
 10:         r.RollupInterval = Report.Interval.Monthly; 
 11:         break; 
 12:     default: 
 13:         r.RollupInterval = Report.Interval.Yearly; 
 14:         break; 
 15: } 

Looking at the code it is very obvious what it is doing, it is setting an enum value based on the string value of a dropdown.  But did it really take that much code to do it.  Well of course not. 

An enumeration type (also named an enumeration or an enum) provides an efficient way to define a set of named integral constants that may be assigned to a variable. For example, assume that you have to define a variable whose value will represent a report interval. There are only 4 meaningful values which that variable will ever store. To define those values, you can use an enumeration type, which is declared by using the enum keyword.

 1: enum ReportInterval
 2: {
 3:     Daily,
 4:     Weekly,
 5:     Monthly,
 6:     Yearly
 7: }
The above enum was declared and then an instance was used on the Report object.
Enums are extremely flexible and can be used in a number of ways.  Lets look at a few ways you can use enums.

Get the Names from the Enum

Lets take the ReportInteval enum we created above and look how we would get an Array of strings that represent the names of each valid enum.

 1: var enumNames = Enum.GetNames(typeof (ReportInterval));

This would allow us to populate that ddlRollupInterval dropdown with all the possible values from the enum

 1: ddlRollupInterval.DataSource = Enum.GetNames(typeof (ReportInterval));
 2: ddlRollupInterval.DataBind();

Ok, so now we have a dropdown filled with the names from the enum, how do we clean up that code we found.  You remember that ugly switch statement that started this whole thing. Once a user selects something in the dropdown and clicks save we want to set the enum based on the string that was selected right? Lets look at how to do that next.

Likewise you can also get the values with the following code:

 1: Array enumValues = Enum.GetValues(typeof(ReportInterval));

Get an Enum from a String

This too is much easier than one would think.  Using the Enum.Parse() method provides a quick way to convert from a string to an instance of the desired Enum.

 1: ReportInterval interval = (ReportInterval)Enum.Parse(typeof(ReportInterval), testString);

This works great in our case because we filled the dropdown with only valid values.  But what if you weren’t sure if the value was valid for the enum or not.  You know those pesky users sometimes give us data that doesn’t fit our model.  ;-)  You can use the Enum.IsDefined() which returns an indication letting us know if a constant with the specified value exists in a specified enumeration.

If our user was able to add a value, say ‘Quarterly’ to our dropdown by some other part of the application and then selected it we would want to test the string we were provided to make sure we don’t throw an unwanted exception.

 1: var ourUserInputString = "Quarterly"
 3: if (Enum.IsDefined(typeof (ReportInterval), outUserInputString)
 4: {
 5:     // It is ok go ahead and pase the enum
 6: }
 7: else
 8: {
 9:     // Alert the user an invalid string was selected.
 10: }

Get an Enum from an Integer

Getting an enum instance form an integer is even easier just cast the integer to the desired Enum.

 1: ReportInterval interval = (ReportInterval) testInt;

Of course we would never let our users add values to the dropdown because we want to constrain the valid values to be one that is on the enum, but I wanted to show you that it can be done.

Limit Method Call Arguments

Another usage for an enum is to limit the values a developer can pass to a method on your object.  Using our ReportInterval enum as an argument to a LoadReport method on our Report call gives us the safety net to know we are only going to get a valid value.  Where as if we just used a string we could get a value that doesn’t make sense.

 1: var status = RunReport(ReportInterval.Daily);

Another great part of this is a that Visual Studio will start complaining that the value is in valid unless it is from the enum, further more the compiler will  an argument '1': cannot convert from 'string' to 'EnumTest.ReportInterval'  exception.  I don’t know about your but I like that.


So what was the final result of fixing the code smell you say?  I replaced that huge 15 line switch statement with the two lines of code, one to verify that the value was correct, remember this is a very, very legacy application and I can not trust that the values were actually loaded to the dropdown from the enum, and one to set the ReportInterval if it checked out good.

I hope that this has shown you just a few ways that the simple Enum can enhance you programming life.


C# Programming Guide: Enumeration Types

How Do Your Convert a String Into an Enum? – Tim Sneath

UGR Episode 4: Interview with Rob Zelt President INETA North America

UGRLogoEpisode 4 of User Group Radio has been released.  While at the MVP Summit in February I got the chance to set down with Rob Zelt the President of INETA North America.  Rob talks about INETA‚Äôs mission, programs, and offers information for User Group Leaders on how they can benefit from being an INETA User Group.

This was a fun interview and Rob talked at length about the role of INETA and how it impacts community.

You can listen to the full episode on the User Group Radio site or subscribe to the feed in your favorite podcatcher.


<<  February 2023  >>

View posts in large calendar

Widget Category list not found.

Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))X

Tag cloud

    Widget Month List not found.

    Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))X

    Widget AuthorList not found.

    Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))X

    Widget TextBox not found.

    Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))X