February
18

Switch Code Snippet For Enums

Posted In: C# by rauchy

Perhaps this is a well-known feature and I’m a moron for posting about it, but I just noticed the switch code snippet.

I was working with this enum:

    public enum AvatarSource
    {
        Gravatar, Uploaded, Web
    }

and I wanted some conditional logic performed, depending on an AvatarSource instance. So I started to type switch and then thought I might use a code snippet for it, so I pressed TAB twice.

Well, I didn’t see this coming.

            switch (avatarSource)
            {
                case AvatarSource.Gravatar:
                    break;
                case AvatarSource.Uploaded:
                    break;
                case AvatarSource.Web:
                    break;
                default:
                    break;
            }

Once you enter the variable for your switch block, the snippet automatically adds a block for each value in your enum.

Sweet.

kick it on DotNetKicks.com

0
February
12

A rerun of all the episodes of "The Simpsons" is on TV every midnight in Israel and last night I had a blast listening to the monorail song.

Castle project peeps, will you consider having this played during installation time?

    

Lyle Lanley: Well, sir, there’s nothing on earth like a genuine, bona fide, electrified, six-car Monorail! What’d I say?
Flanders: Monorail!
Lanley: What’s it called?
Patty & Selma: Monorail!
Lanley: That’s right! Monorail!
[crowd chants ‘Monorail’]

Miss Hoover: I hear those things are awfully loud…
Lanley: It glides as softly as a cloud.
Apu: Is there a chance the track could bend?
Lanley: Not on your life, my Hindu friend.

Barney: What about us brain-dead slobs?
Lanley: You’ll be given cushy jobs.
Abe: Were you sent here by the devil?
Lanley: No, good sir, I’m on the level.

Wiggum: The ring came off my pudding can.
Lanley: Take my pen knife, my good man.
I swear it’s Springfield’s only choice,
Throw up your hands and raise your voice!
All: Monorail!
Lanley: What’s it called?
All: Monorail!
Lanley: Once again…
All: Monorail!

Marge: But Main Street’s still all cracked and broken…
Bart: Sorry, Mom, the mob has spoken!
All: Monorail! Monorail! Monorail!
[big finish] Monorail!
Homer: Mono… D’oh!

(from http://www.simpsoncrazy.com)

kick it on DotNetKicks.com

0