Solved

DriveInfo and DriveType question

Posted on 2014-01-05
2
321 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
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video discusses moving either the default database or any database to a new volume.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now