C # Implementation of USB Interface program code

Source: Internet
Author: User

C # Implementation of the USB Interface program code.

namespace ConsoleApplication1


{


Class Program


  {


static void Main (string[] args)


    {


USB USB;


USB = new Udisk ()//insert U disk


USB. OutputFile ()//Read the file from U disk


USB. Inputfile ()//write file to u disk


USB. Dispose ();//Pull out U disk


Console.WriteLine ("");


USB = new MDisk ()//insert a removable hard drive


USB. OutputFile ()//Read the file from the mobile hard drive


USB. Inputfile ()//write file to mobile hard drive


USB. Dispose ();//unplug the removable hard drive


Console.WriteLine ("");


USB = new MP4 ()//Insert MP4


USB. OutputFile ()//Read files from MP4


USB. Inputfile ()//write file to MP4


USB. Dispose ();/Pull out MP4


Console.readkey ();


    }


//usb Interface


public interface Usb:idisposable


    {


void OutputFile ()//read out file


void Inputfile ()//write file


    }


//u Disk


public class Udisk:usb


    {


public Udisk ()


      {


Console.WriteLine ("U Disk Ready ...");


      }


public void outputfile ()


      {


Console.WriteLine ("Read the file from U disk");


      }


public void Inputfile ()


      {


Console.WriteLine ("Write File to U disk");


      }


public void Dispose ()


      {


Console.WriteLine ("U disk has been unplugged");


      }


    }


//removable hard disk


public class Mdisk:usb


    {


Public MDisk ()


      {


Console.WriteLine ("Mobile HDD Ready ...");


      }


public void outputfile ()


      {


Console.WriteLine ("Read the file from the mobile hard Drive");


      }


public void Inputfile ()


      {


Console.WriteLine ("Write file to mobile hard disk");


      }


public void Dispose ()


      {


Console.WriteLine ("Removable hard drive has been unplugged");


      }


    }


//mp4


public class Mp4:usb


    {


public MP4 ()


      {


Console.WriteLine ("MP4 Ready ...");


      }


public void outputfile ()


      {


Console.WriteLine ("Read the document from the MP4");


      }


public void Inputfile ()


      {


Console.WriteLine ("Write File to MP4");


      }


public void Dispose ()


      {


Console.WriteLine ("MP4 has been pulled out");


      }


    }


  }


}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.