My Namespace and C#:

  • Thread starter Stefano Del Furia
  • Start date
S

Stefano Del Furia

Hi all,
i have downloaded and installed the new version of C# and VB inside the
Visual Studio.NET 2005 suite (beta)
I have try to build some simple test's program and i have found that in VB
i can use the My namespace like My.Application or My.User or My.Forms
I was not able to find they in the C# languages.
I was so surprised and i have made an internet's search and i have find
that C# don't give support for the My namespace.
I think that this is not the most "smart" strategic choice maded by
Microsoft.
I dont' reach to find any reason of dropping support for My namespace in
C# and in the same way i cannot reach to understand why VB don't have
anonymous method.
Please explain to my why MS boys take this "strange" decisions !?!??!?
Stefano
 
C

Chris, Master of All Things Insignificant

Do you mean the "Me" keyword? I believe it is "this" in C#

Chris
 
S

Stefano Del Furia

No, i mean the My Namespace.
This give access to a lot of class about users, computer network and so on.
By
Stefano

In data Wed, 2 Feb 2005 14:14:45 -0600, Chris, Master of All Things
 
M

Mattias Sjögren

I dont' reach to find any reason of dropping support for My namespace in
C#

Since it was never there, nothing is being dropped.

and in the same way i cannot reach to understand why VB don't have
anonymous method.

Believe it or not, but even Microsoft have restrictions on the number
of features they can implement if they ever want to ship a product.



Mattias
 
B

Bob Powell [MVP]

If the My namespace is available to VB it's available to C# as long as the
correct references are made.

OTTOMH try referencing the VisualBasic namespace.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
B

Bruce Wood

Perhaps there is a different way to get the same information in C#.
Tell us what those things do, and maybe we can tell you how to do it in
C#.
 
M

Mattias Sjögren

If the My namespace is available to VB it's available to C# as long as the
correct references are made.

Not all of it. Some parts (e.g. My.Forms) depends on compiler
generated code.



Mattias
 
?

=?ISO-8859-15?Q?Anders_Nor=E5s?=

Stefano said:
I was so surprised and i have made an internet's search and i have find
that C# don't give support for the My namespace.
You can use Visual Basic .NET My services from C# as well, by adding a
reference to Microsoft.VisualBasic.dll to your project.

Here is an example of how to use various "My" services in C#:
class MyClass
{
static void Main(string[] args)
{

// Play a wave sound
Microsoft.VisualBasic.MyServices.MyAudio myAudio = new
MyAudio();
myAudio.Play("mySound.wav");


// Display details about the computer.
Microsoft.VisualBasic.MyServices.MyComputer myComputer =
new MyComputer();
Console.WriteLine("Name: " + myComputer.Name);
Console.WriteLine("Connected to network? " +
myComputer.Network.IsAvailable.ToString());
}
}

Anders Norås
http://dotnetjunkies.com/weblog/anoras/
 
S

Sean Hederman

Stefano Del Furia said:
Hi all,
i have downloaded and installed the new version of C# and VB inside the
Visual Studio.NET 2005 suite (beta)
I have try to build some simple test's program and i have found that in VB
i can use the My namespace like My.Application or My.User or My.Forms
I was not able to find they in the C# languages.

There are often features that are not ported from one programming language
to another. Sometimes because the teams involved don't have time, sometimes
because they're slated for a future release, and sometimes because they
don't fit will to the language philosophy. For example, VB has support for
leaving optional parameters out, while C# does not. The VB philosophy is to
provide a rich developer experience, whilst C# tries to give power and
expressiveness.

Some features in C# 2005, but not in VB: Template Expansions, Iterators,
Anonymous Methods
Features in VB, but not C#: My Namespaces, Default Forms, and I've drawn a
blank for others, although I'm sure there must be some
I was so surprised and i have made an internet's search and i have find
that C# don't give support for the My namespace.
I think that this is not the most "smart" strategic choice maded by
Microsoft.

Many people would disagree with you. I heard much unhappiness that VB was
getting this weird thing called My namespaces. If the VB community was
divided, I'd imagine the C# community would have been rioting in the
streets. Not that I'm accusing C# programmers of being stroppy or anything
;-D
I dont' reach to find any reason of dropping support for My namespace in
C# and in the same way i cannot reach to understand why VB don't have
anonymous method.

You can't drop what was never there. As for anonymous methods, I wouldn't
get upset about that. Their main use will be in making event handlers easier
to code, and VB does that well enough for you. The primary, no 1 reason I
switched from VB to C# was when I heard that VB wasn't getting iterators.
They'd happily put in junk like My Namespaces and Default Forms, but not
iterators which would have dramatically cut my actual work load.
Please explain to my why MS boys take this "strange" decisions !?!??!?
Stefano

Often for very good reasons. I may whinge bitterly about the direction VB
has taken, but the fact of the matter is that it has a clearly defined
vision and is following that. As has C#. You may not agree with some of the
decisions (and I certainly don't), but that doesn't neccesarily make them
bad decisions for the product team. It makes them bad decisions for you :-D
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top