Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2005

Tip: Looking for answers? Try searching our database.

Long Class Name

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jim Heavey - 18 Oct 2005 21:38 GMT
I have a Static class which has a very large name which belongs to the same
Namespace as the class that I am working in.  I want to create an "alias" for
this "big class name" so that I can save keystrokes and make the program more
readable.  I am not sure how to do this globally within the class that I am
working.

Is there some way to do this?

So instead of typing
MyGiganticInformativeClassName.DoSomething()
I want to use
MGIC.DoSomething();
Aarthi - 18 Oct 2005 22:02 GMT
Unfortunately, I don't think you can. A work-around though. What about having
a static property in your class that just serves as a wrapper for this
gigantic class name
such as
class SClass
{
string SomeValue
{
get
{
return LognClassName.SomeValue;
}
set
{
LongClassName.SomeValue=value;
}

}
}
Signature

Aarthi R S

> I have a Static class which has a very large name which belongs to the same
> Namespace as the class that I am working in.  I want to create an "alias" for
[quoted text clipped - 8 lines]
> I want to use
> MGIC.DoSomething();
Dirc Khan-Evans - 19 Oct 2005 09:26 GMT
> I have a Static class which has a very large name which belongs to
> the same Namespace as the class that I am working in.  I want to
[quoted text clipped - 8 lines]
> I want to use
> MGIC.DoSomething();

Yes.. this is entirely possible using "Using alias directives"

From the documentation:

A using-alias-directive introduces an identifier that serves as an
alias for a namespace or type within the immediately enclosing
compilation unit or namespace body.

using-alias-directive:
using   identifier   =   namespace-or-type-name   ;
Within member declarations in a compilation unit or namespace

For more information take a look at the MSDN documentation.

Dirc
Dirc Khan-Evans - 19 Oct 2005 09:45 GMT
> I have a Static class which has a very large name which belongs to
> the same Namespace as the class that I am working in.  I want to
[quoted text clipped - 8 lines]
> I want to use
> MGIC.DoSomething();

Of course the real question is why you decided to use a long name in
the first place and now want to use an alias?

Personally, I like long names if they are descriptive and helpful. If
you have used this name in the first case, I think it makes code more
readable and understandable if you use this name throughout your code.

Dirc
Aarthi - 19 Oct 2005 13:49 GMT
sorry..Two minutes after I posted this, I realized what Dirk has posted..you
can use something like
using AliasToMyClass = NameSpace1.MyClass;
Signature

Aarthi R.S

> I have a Static class which has a very large name which belongs to the same
> Namespace as the class that I am working in.  I want to create an "alias" for
[quoted text clipped - 8 lines]
> I want to use
> MGIC.DoSomething();

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.