Solved

DriveInfo and DriveType question

Posted on 2014-01-05
2
325 Views
Last Modified: 2014-01-05
DriveInfo info = new DriveInfo(drive);
        switch (info.DriveType)
        {
          case DriveType.CDRom:
            Console.WriteLine("CDROM drive");
            break;

Why does this code from a tutorial have "case DriveType.CdRom" instead of just "case CDRom"?

I thought that if info.DriveType is a property that returns a string, than it would return "CDRom". So why the leading DriveType in DriveType.CDRom?
0
Comment
Question by:BobHavertyComh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 44

Assisted Solution

by:AndyAinscow
AndyAinscow earned 300 total points
ID: 39757742
>>I thought that if info.DriveType is a property that returns a string

Wrong.
http://msdn.microsoft.com/en-us/library/system.io.driveinfo.drivetype%28v=vs.110%29.aspx
info.DriveType returns a DriveType not a string, see:
http://msdn.microsoft.com/en-us/library/system.io.drivetype%28v=vs.110%29.aspx
0
 
LVL 10

Accepted Solution

by:
Korbus earned 200 total points
ID: 39757770
Anby is correct.  The value DriveType.CDROM, is technically called an ENUMERATION, (which usually equates to a particular number, behind the scenes), rather than a STRING.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question