I borrowed my from VB, and C # followed the entire road to Rome.

Source: Internet
Author: User

. NET Framework No one can deny its wide and deep functionality and completeness. However, a large number of categories in its many namespaces often give new users no idea where to start, it will always take a while to get familiar with what they need. This process is a bit frustrating. To solve learning problems and improve developers' productivity, Visualized basic 2005 Provides a very important new function, which is My . My Provides common . NET Framework Class and function entry point, so that common functions are at your fingertips, and reduce the numberProgramCodeNumber of rows. Is it just such a useful function? Visual C #2005 Cannot it be used? In fact, you only need to add Microsoft. VisualBasic And then import the appropriate namespace, for example:

UsingMicrosoft. VisualBasic. devices;

You can Visual C #2005 Used My Similar syntax to write programs. Now suppose we want Visual C #2005 To play an audio file. C # The program syntax should be as follows:

Soundplayer simplesound = new soundplayer (@"C: \ beep.wav");

Simplesound. Play ();


Now we haveMyYou only need to write the following two statements:

ComputerMyowncomputer = newComputer ();

Myowncomputer. Audio. Play (@ "C: \ beep.wav ");


For example, if you want to play a system sound, you can write the following statement:

ComputerMyowncomputer = newComputer ();

 

Myowncomputer. Audio. playsystemsound (

System. Media. systemsounds. Asterisk );


For another example, if you want to verify the connection with the specified remote host, you can write the following code:

ComputerMyowncomputer = newComputer ();

 

If (myowncomputer.Network. isavailable)

{

 If (myowncomputer.Network. Ping ("www.microsoft.com "))

 {

MessageBox. Show ("Microsoft websites can be used.");

 }

}


We can see from the three examples above,ApparentlyMyNot only can the program code be more streamlined, but more importantly, this is a very intuitive way of writing, allowing programmers to easily associate and explore the required functions.

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.