?
Solved

DriveInfo and DriveType question

Posted on 2014-01-05
2
Medium Priority
?
328 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 1200 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 800 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

752 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