بابک زواری
یک شنبه 13 شهریور 1384, 18:03 عصر
یکی از امکانات جالب VB.Net استفاده از My namespace هست که در #C گنجانده نشده شما با کمک مقاله زیر این امکان رو به #C اضافه میکنید .
به امید روزی که #C هم به اندازه VB.Net قوی و مطمئن شود :متعجب: :گیج: :عصبانی: :لبخند:
My namespace with C# 2.0
Introduction
This article/tutorial talks about the My namespace, which is a new feature available only within the Microsoft .NET Framework 2.0 and VB .NET 2005.
About My
With the latest release of Visual Studio .NET 2005 codenamed "Whidbey", VB .NET 2005 has been shipped with one extra class in the .NET Framework 2.0 BCL. These VB .NET 2005 "My namespace’s" will help to write difficult code with ease.
For example; accessing computer information, reading the computer clock, opening ports, accessing the network, files etc.
Since this most fascinating feature is VB.NET 2005 specific. Which is aimed to help VB.NET developers and C# geeks.
Accessing My with C#
The idea of accessing My lies in the core of the .NET Framework 2.0 BCL (Base Class Library). The My namespace has its implementation in an assembly named Micrisoft.VisualBasic.dll and uses the Microsoft.VisualBasic.MyServices namespace.
By having a reference to this assembly, the functionality of the My namespace can be used with C#.
Code Example
The example below shows how to call My in C# and use its functionality.
Step - 1
Run Visual Studio .NET 2005 (Whidbey)
File -> New -> Project -> Visual C# -> Console Application
Step - 2
Add Reference to Microsoft.VisualBasic.dll under References
http://www.programmersheaven.com/articles/faq/csharp/image001.gif
Step - 3
Add the following line under using directive
using Microsoft.Visualbasic.MyServices;
and then add the code to call the functionality
http://www.programmersheaven.com/articles/faq/csharp/image002.gif
Step - 4
Run the application and see the output.
http://www.programmersheaven.com/articles/faq/csharp/image003.gif
Conclusion
This article/tutorial briefly introduced the My namespace and how to access My with C#.
Another point is "why is My a VB .NET 2005 only feature?". The reason I can think is that perhaps Visual Basic is a language which has been greatly recognized for its IDE and Intellisense features and this is what satisfies the term RAD. Maybe this is why it is available with VB .NET 2005 (by default) and not with C#?
The VB .NET Code Editor recognizes My and it is a Language Enhancement within VB .NET 2005.
Since the My namespace is the part of the .NET Framework 2.0 BCL (Base Class Library), implementation of Microsoft.VisualBasic.dll assembly.
About the Author
Vidya Vrat Agarwal, a Microsoft Purist, and an MCSD.NET, MCAD, MCSD, MCT. I started working on Microsoft.NET with its beta release. I have been involved in corporate trainings, software development, T3 programs, technical writing and consultation for Microsoft.NET for various corporate clients. Presently I am working with Proteans Software Solution company in India's Silicon Velly Bangalore, and my business card reads Chief .NET Evangelist.
My technical profile holds .NET Framework, VC#, VB.NET, WebServices, .NET Remoting, SQL Server, COM, DCOM, COM+, MTS, MSMQ, Whidbey, Yukon and Longhorn..
My blog can be read at http://dotnetpassion.blogspot.com (http://dotnetpassion.blogspot.com/)
به امید روزی که #C هم به اندازه VB.Net قوی و مطمئن شود :متعجب: :گیج: :عصبانی: :لبخند:
My namespace with C# 2.0
Introduction
This article/tutorial talks about the My namespace, which is a new feature available only within the Microsoft .NET Framework 2.0 and VB .NET 2005.
About My
With the latest release of Visual Studio .NET 2005 codenamed "Whidbey", VB .NET 2005 has been shipped with one extra class in the .NET Framework 2.0 BCL. These VB .NET 2005 "My namespace’s" will help to write difficult code with ease.
For example; accessing computer information, reading the computer clock, opening ports, accessing the network, files etc.
Since this most fascinating feature is VB.NET 2005 specific. Which is aimed to help VB.NET developers and C# geeks.
Accessing My with C#
The idea of accessing My lies in the core of the .NET Framework 2.0 BCL (Base Class Library). The My namespace has its implementation in an assembly named Micrisoft.VisualBasic.dll and uses the Microsoft.VisualBasic.MyServices namespace.
By having a reference to this assembly, the functionality of the My namespace can be used with C#.
Code Example
The example below shows how to call My in C# and use its functionality.
Step - 1
Run Visual Studio .NET 2005 (Whidbey)
File -> New -> Project -> Visual C# -> Console Application
Step - 2
Add Reference to Microsoft.VisualBasic.dll under References
http://www.programmersheaven.com/articles/faq/csharp/image001.gif
Step - 3
Add the following line under using directive
using Microsoft.Visualbasic.MyServices;
and then add the code to call the functionality
http://www.programmersheaven.com/articles/faq/csharp/image002.gif
Step - 4
Run the application and see the output.
http://www.programmersheaven.com/articles/faq/csharp/image003.gif
Conclusion
This article/tutorial briefly introduced the My namespace and how to access My with C#.
Another point is "why is My a VB .NET 2005 only feature?". The reason I can think is that perhaps Visual Basic is a language which has been greatly recognized for its IDE and Intellisense features and this is what satisfies the term RAD. Maybe this is why it is available with VB .NET 2005 (by default) and not with C#?
The VB .NET Code Editor recognizes My and it is a Language Enhancement within VB .NET 2005.
Since the My namespace is the part of the .NET Framework 2.0 BCL (Base Class Library), implementation of Microsoft.VisualBasic.dll assembly.
About the Author
Vidya Vrat Agarwal, a Microsoft Purist, and an MCSD.NET, MCAD, MCSD, MCT. I started working on Microsoft.NET with its beta release. I have been involved in corporate trainings, software development, T3 programs, technical writing and consultation for Microsoft.NET for various corporate clients. Presently I am working with Proteans Software Solution company in India's Silicon Velly Bangalore, and my business card reads Chief .NET Evangelist.
My technical profile holds .NET Framework, VC#, VB.NET, WebServices, .NET Remoting, SQL Server, COM, DCOM, COM+, MTS, MSMQ, Whidbey, Yukon and Longhorn..
My blog can be read at http://dotnetpassion.blogspot.com (http://dotnetpassion.blogspot.com/)