Enumerations and the switch Decision Statement - 19
- Posted: Nov 21, 2011 at 9:28 AM
- 5,018 Views
- 2 Comments
Download
How do I download the videos?
- To download, right click the file type you would like and pick “Save target as…” or “Save link as…”
Why should I download videos from Channel9?
- It's an easy way to save the videos you like locally.
- You can save the videos in order to watch them offline.
- If all you want is to hear the audio, you can download the MP3!
Which version should I choose?
- If you want to view the video on your PC, Xbox or Media Center, download the High Quality WMV file (this is the highest quality version we have available).
- If you'd like a lower bitrate version, to reduce the download time or cost, then choose the Medium Quality WMV file.
- If you have a Zune, WP7, iPhone, iPad, or iPod device, choose the low or medium MP4 file.
- If you just want to hear the audio of the video, choose the MP3 file.
Right click “Save as…”
- High Quality WMV (PC, Xbox, MCE)
- MP3 (Audio only)
- High Quality MP4 (iPad, PC)
- MP4 (iPod, Zune HD)
- Mid Quality MP4 (WP7, HTML5)
Classes can contain many different types of information, not just Properties and Methods. We begin demonstrating the use of Enumerations because often in the .NET Framework Class Library, properties can only be set to a pre-determined subset of possible values. To illustrate this point we create our own custom enumeration, and then utilize it in a simple application that demonstrates a third Decision statement, the switch. We demonstrate some Visual Studio IDE magic that will automatically implement code blocks for all possible enumeration values.
Comments Closed
Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation,
please create a new thread in our Forums,
or
Contact Us and let us know.
Follow the Discussion
A found it a little misleading when you (Bob) refer to the ComplexIfStatement, kind of inferred or suggested that the Select Case decision statement can't do what the ComplexIfStatement does. (Especially with Option Strict Off)
See Example Below.
Module Module1 Sub Main() SelectCase_Example() Console.WriteLine() SuperHero_Example() Console.ReadLine() End Sub Public Sub SelectCase_Example() Console.WriteLine("Select Case Example") Dim value = 42 Select Case value Case Is < 1, Is > 100 : Console.WriteLine("Out of bounds") Case 23, 42, Is > 90 : Console.WriteLine("You Found one of the special numbers") Case Else Console.WriteLine("Not one of special numbers") End Select End Sub Public Sub SuperHero_Example() Console.WriteLine("SuperHero Example") GreetSuperHero(11) GreetSuperHero(SuperHeros.Batman) End Sub Public Sub GreetSuperHero(ByVal superhero As SuperHeros) Dim IsMemberOfSuperHeros = [Enum].IsDefined(GetType(SuperHeros), superhero) If IsMemberOfSuperHeros Then Console.WriteLine("Hello: {0}", superhero.ToString) Else Console.WriteLine("How Are You?") End If End Sub Enum SuperHeros Superman Batman Spiderman End Enum End ModuleWhen you use Enumerations it can be of any value that the underlying type can be.
See Example Code above
@AdamSpeight2008:Awesome, awesome comment. Thank you! When we re-do this video I'll make sure to revise as you have advised.
Remove this comment
Remove this thread
close