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
Solved

DriveInfo and DriveType question

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

860 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