Reputation: 136633
No I'm not being a wise guy ...
For those fortunate enough to not know the My class: It's something that was added in VB 2005 (and doesn't exist in C#) and is best described as a 'speeddial for the .net framework'. Supposed to make life easier for newbies who won't read which framework classes they should be using
Dim contents As String
contents = My.Computer.FileSystem.ReadAllText("c:\mytextfile.txt")
Instead of this:
Dim contents As String
contents = IO.File.ReadAllText("c:\mytextfile.txt")
My Question: Where is the MSDN documentation page for which speeddial button maps to what.. ?
By choosing the name of the feature as My - they've just made searching a whole lot more fun that it needs to be. I need to code in C# and can't bear the fun of translating the training/how-to office prog videos which exclusively deal in VB.
More on this from the Dans
Juval Lowy ported My as That in C# as an interim solution. Don't ask me why...
Upvotes: 8
Views: 429
Reputation: 545608
Different features inside the My
namespace behave very differently and are implemented using different techniques. There's not “one” documentation for them, unfortunately.
Many of the shortcut methods refer to classes within the Microsoft.VisualBasic.dll. You can of course reference this from C#.
Some mappings (by no means complete):
My.Application
=> Microsoft.VisualBasic.ApplicationServices.ApplicationBase
This class is inherited from to produce the Application Framework of VB.
My.Computer
=> Microsoft.VisualBasic.Devices.ServerComputer
My.User
=> Microsoft.VisualBasic.ApplicationServices.User
My.Settings
=> Maps directly to C#'s RootNamespace.Properties.Settings
My.Resources
=> Maps directly to C#'s RootNamespace.Properties.Resources
Upvotes: 0
Reputation: 52829
The official reference for the My namespace can be found here on MSDN.
Unfortunately, it doesn't describe which 'real' Framework features the My shortcuts map to (although this isn't too hard to figure out in most cases).
As a further annoyance, the source code isn't released as part of the .NET Reference Source either (same situation as with Microsoft.VisualBasic, even though being able to check the source would do a lot to demystify this part of the Framework...)
Upvotes: 1
Reputation: 1500695
It's the "My namespace" rather than the "My class" which may aid searching.
So far I've found this: http://msdn.microsoft.com/en-us/vbasic/ms789188.aspx but it's not ideal. Looking for more...
EDIT: I think "Developing with My" is effectively the root of the documentation.
Upvotes: 2
Reputation: 1062865
This looks promising - it is a detailed account of the MyServices area (that provides My in VB)
Some more is here.
Upvotes: 0