473,388 Members | 1,417 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Definition problem

How can i declare a definition with using (using a = b.c.d) and use it in
all files of my project without rewrite it in every file of my project ?
And if i want to permit the use of this alias to the user of my library ?
In C++ i use the #define instruction in a .h file and i include it in every
file i want to use alias. how can i do it in c# ?
Nov 15 '05 #1
9 1896
Abbiento,

You can not do this. Includes (in the C++ sense), are not a feature of
C#. So, for every file, you will have to place the "using" directive there
yourself.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Abbiento Morgan" <mo****@abbiento.com> wrote in message
news:uo**************@TK2MSFTNGP09.phx.gbl...
How can i declare a definition with using (using a = b.c.d) and use it in
all files of my project without rewrite it in every file of my project ?
And if i want to permit the use of this alias to the user of my library ?
In C++ i use the #define instruction in a .h file and i include it in every file i want to use alias. how can i do it in c# ?

Nov 15 '05 #2
Nad ther'isnt solution for my problem ?

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> ha
scritto nel messaggio news:%2****************@tk2msftngp13.phx.gbl...
Abbiento,

You can not do this. Includes (in the C++ sense), are not a feature of C#. So, for every file, you will have to place the "using" directive there yourself.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Abbiento Morgan" <mo****@abbiento.com> wrote in message
news:uo**************@TK2MSFTNGP09.phx.gbl...
How can i declare a definition with using (using a = b.c.d) and use it in all files of my project without rewrite it in every file of my project ?
And if i want to permit the use of this alias to the user of my library ? In C++ i use the #define instruction in a .h file and i include it in

every
file i want to use alias. how can i do it in c# ?


Nov 15 '05 #3
Abbiento Morgan <mo****@abbiento.com> wrote:
Nad ther'isnt solution for my problem ?


I'd suggest that the best solution is to avoid doing the alias in the
first place. In general it's likely to reduce readability, as people
may be familiar with class named "d" but not "a" (if you see what I
mean).

I can't say I've ever used aliases in production code. (The only times
I've used them in test code is to investigate what they get can do.)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #4

I cant think there isnt a solution for declare a global variable or a
global alias...

--------------------------
Abbiento Morgan <
GlobalTech S.a.s <
fo***@abbiento.com <

--------------------------

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #5
Morghan <fo***@abbiento.com> wrote:
I cant think there isnt a solution for declare a global variable or a
global alias...


There's a very good reason for it though - .NET is an object-oriented
platform, and "global alias" and "global variable" are not OO ideas.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #6
Yes i know but sometimes there is very good reason for have global alias...

"Jon Skeet [C# MVP]" <sk***@pobox.com> ha scritto nel messaggio
news:MP************************@msnews.microsoft.c om...
Morghan <fo***@abbiento.com> wrote:
I cant think there isnt a solution for declare a global variable or a
global alias...


There's a very good reason for it though - .NET is an object-oriented
platform, and "global alias" and "global variable" are not OO ideas.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 15 '05 #7
Abbiento Morgan <fo***@abbiento.com> wrote:
Yes i know but sometimes there is very good reason for have global alias...


Such as? I haven't seen any examples which aren't clearer using a
singleton or whatever, myself.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #8
An example can be when you must create an alias for permit to your user of
write most simple code instead of a list of nested class.

"Jon Skeet [C# MVP]" <sk***@pobox.com> ha scritto nel messaggio
news:MP************************@msnews.microsoft.c om...
Abbiento Morgan <fo***@abbiento.com> wrote:
Yes i know but sometimes there is very good reason for have global
alias...
Such as? I haven't seen any examples which aren't clearer using a
singleton or whatever, myself.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 15 '05 #9
Abbiento Morgan <fo***@abbiento.com> wrote:
An example can be when you must create an alias for permit to your user of
write most simple code instead of a list of nested class.


But they can write a single using statement themselves at the top of
their own code. That way their code is more self-documenting. If they
need to understand where a particular alias comes from, it's right
there in their own code. In particular, they can also choose the alias
*they're* most happy with, rather than one *you've* picked.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Neil Zanella | last post by:
Hello, I have posted the following message before but got no replies... I am trying to format an HTML definition list with CSS so that it appears as follows, but am having the following problem:...
3
by: DanielBradley | last post by:
Hello all, I have recently been porting code from Linux to cygwin and came across a problem with static const class members (discussed below). I am seeking to determine whether I am programming...
4
by: Ced | last post by:
Hi, i'm not an expert in C but i try to compile BTNG software under linux kernel 2.4.2-2. I get these errors at the very first stage. Does someone could have a rapid look on this and tell me...
2
by: Alfonso Alvarez | last post by:
Hi: I'm doing a web page using asp.net and framework 1.1. When I upload the page to server and try it with html validator of w3c, trying with html 4.01 an xhtml 1.0, I receive an error in the...
2
by: xllx.relient.xllx | last post by:
I have a few quetions about definitions vs declarations concerning defined types (user defined), specifically classes. From what I understand, a class contained in a header file is a definition as...
2
by: Emmanuel Deloget | last post by:
Hello, I'm trying to find a (sfinae powered) way to verify if a particular type declares a subtype (either using typedef or by declaring a subclass). To be more concrete, let's say that I'm...
8
by: nishit.gupta | last post by:
I was having a problem with template class memer function definition , so i serched the net and find that template class member fuction definition should be in header file else compilation will...
9
by: Jess | last post by:
Hello, I was told that if I declare a static class constant like this: class A{ static const int x = 10; }; then the above statement is a declaration rather than a definition. As I've...
13
by: Old Wolf | last post by:
I have some code that has in the header file: void foo( char bar ); and in the source file: void foo( bar ) char bar; { /* etc. */ } The compiler (with many warnings enabled) warns that...
275
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.