Home All Groups Group Topic Archive Search About

Specifiy that i'm referring to a class, not a member

Author
21 Sep 2006 3:10 PM
wingphil
Hi all,

I've got a class in my project called Location - it has some shared
members that I can't reference from within a form because forms have a
property called location. Short fo renaming the class or putting
Projectname.Location.Member which is a bit wordy for my liking, how can
I tell the compiler I'm talking about the Location class, not the
Location member? I'm using VS 2003.

Thanks very much for any help you can offer,

Phil

Author
21 Sep 2006 3:17 PM
Mythran
<wingp***@yahoo.com> wrote in message
Show quoteHide quote
news:1158851454.566290.278200@d34g2000cwd.googlegroups.com...
> Hi all,
>
> I've got a class in my project called Location - it has some shared
> members that I can't reference from within a form because forms have a
> property called location. Short fo renaming the class or putting
> Projectname.Location.Member which is a bit wordy for my liking, how can
> I tell the compiler I'm talking about the Location class, not the
> Location member? I'm using VS 2003.
>
> Thanks very much for any help you can offer,
>
> Phil
>

You could use "Imports MyLoc = MyNamespace.Location".  Then you could use
MyLoc.MemberHere :)

HTH,
Mythran
Author
21 Sep 2006 3:29 PM
wingphil
That's great, didn't know you could do that :)

Thanks Mythran!

Phil

Mythran wrote:
Show quoteHide quote
> <wingp***@yahoo.com> wrote in message
> news:1158851454.566290.278200@d34g2000cwd.googlegroups.com...
> > Hi all,
> >
> > I've got a class in my project called Location - it has some shared
> > members that I can't reference from within a form because forms have a
> > property called location. Short fo renaming the class or putting
> > Projectname.Location.Member which is a bit wordy for my liking, how can
> > I tell the compiler I'm talking about the Location class, not the
> > Location member? I'm using VS 2003.
> >
> > Thanks very much for any help you can offer,
> >
> > Phil
> >
>
> You could use "Imports MyLoc = MyNamespace.Location".  Then you could use
> MyLoc.MemberHere :)
>
> HTH,
> Mythran
Author
21 Sep 2006 3:45 PM
zacks
wingp***@yahoo.com wrote:
> That's great, didn't know you could do that :)
>
> Thanks Mythran!
>
> Phil

I use that same trick to provide shortcut references to VB functions as
in:

Imports VB = MicrosoftVisualBasic

If VB.Left(blah) ...


Show quoteHide quote
>
> Mythran wrote:
> > <wingp***@yahoo.com> wrote in message
> > news:1158851454.566290.278200@d34g2000cwd.googlegroups.com...
> > > Hi all,
> > >
> > > I've got a class in my project called Location - it has some shared
> > > members that I can't reference from within a form because forms have a
> > > property called location. Short fo renaming the class or putting
> > > Projectname.Location.Member which is a bit wordy for my liking, how can
> > > I tell the compiler I'm talking about the Location class, not the
> > > Location member? I'm using VS 2003.
> > >
> > > Thanks very much for any help you can offer,
> > >
> > > Phil
> > >
> >
> > You could use "Imports MyLoc = MyNamespace.Location".  Then you could use
> > MyLoc.MemberHere :)
> >
> > HTH,
> > Mythran
Author
21 Sep 2006 4:17 PM
Mythran
<za***@construction-imaging.com> wrote in message
Show quoteHide quote
news:1158853552.850740.136330@e3g2000cwe.googlegroups.com...
>
> wingp***@yahoo.com wrote:
>> That's great, didn't know you could do that :)
>>
>> Thanks Mythran!
>>
>> Phil
>
> I use that same trick to provide shortcut references to VB functions as
> in:
>
> Imports VB = MicrosoftVisualBasic
>
> If VB.Left(blah) ...
>
>

Usually, we don't do that in our office.  But once in a great while, there
comes a time where two namespaces collide.  For example:

SomeCompany.Security.Principal namespace, System.Security.Principal
namespace and OurCompany.Security.Principal namespace.  We don't want to
type out the full namespace, so we just use the specified imports shortcut.
Another thing that we usually don't use, but have done...albeit rarely, is
import a class directly so that we don't have to type out the class name....

Example:
We have a class named Common with all shared members.  We just want to call
the members/methods directly without specifying Common everywhere... (this
only works in VB.Net and not C# afaik)...
Imports OurNamespace.OurApplication.Common

Here we directly import the namespace + classname and now instead of
Common.MethodName() we can just use MethodName()  ...

Cheers!

Mythran