定义问题 [英] Definition problem

查看:67
本文介绍了定义问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用(使用a = bcd)声明一个定义并在

中使用它我的项目的所有文件而不在我的项目的每个文件中重写它?

如果我想允许对我的库用户使用这个别名?

在C ++中我使用.h文件中的#define指令并将其包含在每个

文件我想使用别名。我该怎么办c#?

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# ?

推荐答案

Abbiento,


你不能这样做。包含(在C ++意义上),不是

C#的功能。因此,对于每个文件,您都必须放置使用文件。指令那里

你自己。


希望这会有所帮助。


-

- Nicholas Paldino [.NET / C#MVP]

- mv*@spam.guard.caspershouse.com


" Abbiento Morgan" <莫**** @ abbiento.com>在消息中写道

news:uo ************** @ TK2MSFTNGP09.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...
我如何声明一个定义使用(使用a = bcd)并在我的项目的所有文件中使用它而不在我的项目的每个文件中重写它?
如果我想允许使用此别名给用户我的库?
在C ++中,我在.h文件中使用#define指令,并将其包含在每个我希望使用别名的文件的
中。我该怎么办c#?
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# ?



Nad ther''ntnt解决我的问题?


Nicholas Paldino [.NET / C#MVP]" < mv*@spam.guard.caspershouse.com> ha

scritto nel messaggio新闻:%2 **************** @ tk2msftngp13.phx.gbl ...
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 ,

你不能这样做。包含(在C ++意义上),不是C#的
功能。因此,对于每个文件,您都必须放置使用文件。指令
自己。

希望这会有所帮助。

-
- Nicholas Paldino [.NET / C#MVP]
- < a href =mailto:mv*@spam.guard.caspershouse.com> mv*@spam.guard.caspershouse.com

Abbiento Morgan <莫**** @ abbiento.com>在消息中写道
新闻:uo ************** @ TK2MSFTNGP09.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...
如何使用(声明定义)使用a = bcd)并在项目的所有文件中使用
而不在我的项目的每个文件中重写它?
如果我想允许使用此别名给我的库的用户
?在C ++中,我在.h文件中使用#define指令,并将其包含在
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


每个

文件中我想使用别名。我怎么能用c#?
file i want to use alias. how can i do it in c# ?




Abbiento Morgan< mo **** @ abbiento .COM>写道:
Abbiento Morgan <mo****@abbiento.com> wrote:
Nad ther''isnt解决我的问题?
Nad ther''isnt solution for my problem ?




我建议最好的解决方案是避免这样做别名在

的第一名。一般来说,它可能会降低可读性,因为人们可能熟悉名为d的类。但不是a (如果你看到我b $ b的意思)。


我不能说我曾经在生产代码中使用过别名。 (唯一的一次

我在测试代码中使用它们是为了调查它们可以做什么。)


-

Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet

如果回复小组,请不要给我发邮件



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


这篇关于定义问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆