. 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.