CS0617:读写属性属性 [英] CS0617: read-write attribute properties

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

问题描述




是否有理由要求C#要求属性参数(属性)为/ b $ b读写时VB和C ++满意只有一个二传手?


简化示例:


公共密封类FooAttribute:属性

{

private string s;

public string Data {set {s = value; } $;

}

[Foo(Data =" bar")]在C#中不起作用,但在VB.NET和C ++中起作用。


Jens。


-
http://ManagedXLL.net/ | http://jens-thiel.de/ | http://QuantLib.net/

用我的第一个替换MSDN回复我的电子邮件地址时的名字!

Hi,

is there a reason for C# to require attribute arguments (properties) to be
read-write while VB and C++ are happy with only a setter?

Simplified Example:

public sealed class FooAttribute : Attribute
{
private string s;
public string Data { set { s = value; } };
}
[Foo(Data="bar")] won''t work in C#, but in VB.NET and C++.

Jens.

--
http://ManagedXLL.net/ | http://jens-thiel.de/ | http://QuantLib.net/
Replace MSDN with my first name when replying to my email address!

推荐答案

Jens,


我相信这是一个尝试使用该语言的设计者

来强制执行良好的设计(思考是什么时候你会写一个值并且

无法读取它?)。


希望这会有所帮助。

-

- Nicholas Paldino [.NET / C#MVP]

- mv*@spam.guard.caspershouse.com


" Jens Thiel < MS ** @ Thiel.de>在消息中写道

news:uX ************** @ tk2msftngp13.phx.gbl ...
Jens,

I believe it''s an attempt on the part of the designers of the language
to enforce good design (the thinking being when would you write a value and
not be able to read it?).

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

"Jens Thiel" <MS**@Thiel.de> wrote in message
news:uX**************@tk2msftngp13.phx.gbl...

C#是否有理由要求属性参数(属性)是读写的,而VB和C ++只对setter感到满意?

简化示例:<公共密封类FooAttribute:Attribute
{private string s;
public string Data {set {s = value; } $; $

[Foo(Data =" bar")]在C#中不起作用,但在VB.NET和C ++中起作用。
Jens。

-
http://ManagedXLL.net/ | http://jens-thiel.de/ | http://QuantLib.net/
在回复时,用我的名字替换MSDN我的电子邮件地址!
Hi,

is there a reason for C# to require attribute arguments (properties) to be
read-write while VB and C++ are happy with only a setter?

Simplified Example:

public sealed class FooAttribute : Attribute
{
private string s;
public string Data { set { s = value; } };
}
[Foo(Data="bar")] won''t work in C#, but in VB.NET and C++.

Jens.

--
http://ManagedXLL.net/ | http://jens-thiel.de/ | http://QuantLib.net/
Replace MSDN with my first name when replying to my email address!



好吧,


不是我的决定我如何从属性中检索某些东西?在

这种情况​​下,它是一个int []数组,也是原始设计,直到它b / b
结果表明当前的VB.NET不能处理数组属性属性。


我认为这是一个不必要的设计限制,VB和

C ++团队都没有遵循这一点。你有没有办法向

语言设计师提出建议?


Jens。


-
http://ManagedXLL.net/ | http://jens-thiel.de/ | http://QuantLib.net/

用我的第一个替换MSDN回复我的电子邮件地址时的名字!

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

消息新闻:Oj ************** @ TK2MSFTNGP10.phx.gbl ...
Well,

isn''t it my part to decide how I retrieve something from an attribute? In
this case, it''s an int[] array, which was also the original design until it
turned out that the current VB.NET can''t handle array attribute properties.

I think that this is an unnecessary design restriction, and both the VB and
C++ teams didn''t follow this. Do you know a way to suggest this to the
"language designers"?

Jens.

--
http://ManagedXLL.net/ | http://jens-thiel.de/ | http://QuantLib.net/
Replace MSDN with my first name when replying to my email address!
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:Oj**************@TK2MSFTNGP10.phx.gbl...
Jens,
我相信这是语言设计师的一次尝试,以强制执行良好的设计(这种想法是什么时候你会写一个价值
而不能阅读它?)。

希望这会有所帮助。

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

Jens Thiel < MS ** @ Thiel.de>在消息中写道
新闻:uX ************** @ tk2msftngp13.phx.gbl ...
Jens,

I believe it''s an attempt on the part of the designers of the language
to enforce good design (the thinking being when would you write a value and not be able to read it?).

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

"Jens Thiel" <MS**@Thiel.de> wrote in message
news:uX**************@tk2msftngp13.phx.gbl...

有没有理由让C#要求属性参数(属性)到
是读写的,而VB和C ++只对setter感到高兴?

简化示例:
<公共密封类FooAttribute:属性
{私有字符串s;
公共字符串数据{set {s = value; } $; $

[Foo(Data =" bar")]在C#中不起作用,但在VB.NET和C ++中起作用。
Jens。

-
http://ManagedXLL.net/ | http://jens-thiel.de/ |
http://QuantLib.net/ 回复时,用我的名字替换MSDN我的电子邮件地址!
Hi,

is there a reason for C# to require attribute arguments (properties) to be read-write while VB and C++ are happy with only a setter?

Simplified Example:

public sealed class FooAttribute : Attribute
{
private string s;
public string Data { set { s = value; } };
}
[Foo(Data="bar")] won''t work in C#, but in VB.NET and C++.

Jens.

--
http://ManagedXLL.net/ | http://jens-thiel.de/ | http://QuantLib.net/ Replace MSDN with my first name when replying to my email address!




http://msdn.microsoft.com/vcsharp/te...k/default.aspx


您是否考虑过使用属性的构造函数来传递

数组?


" Jens Thiel" < MS ** @ Thiel.de>在消息中写道

新闻:OP ************** @ TK2MSFTNGP09.phx.gbl ...
http://msdn.microsoft.com/vcsharp/te...k/default.aspx

Have you considered using the constructor of the attribute to pass in your
array?

"Jens Thiel" <MS**@Thiel.de> wrote in message
news:OP**************@TK2MSFTNGP09.phx.gbl...
嗯,

我决定如何从属性中检索某些东西不是我的职责吗?在这种情况下,它是一个int []数组,它也是原始设计,直到
结果是当前VB.NET无法处理数组属性
属性。
我认为这是一个不必要的设计限制,VB
和C ++团队都没有遵循这一点。你有没有办法向
语言设计师提出建议?

Jens。

-
http://ManagedXLL.net/ | http://jens-thiel.de/ | http://QuantLib.net/
在回复时,用我的名字替换MSDN我的电子邮件地址!

" Nicholas Paldino [.NET / C#MVP]" < mv*@spam.guard.caspershouse.com>在消息新闻中写了
:Oj ************** @ TK2MSFTNGP10.phx.gbl ...
Well,

isn''t it my part to decide how I retrieve something from an attribute? In
this case, it''s an int[] array, which was also the original design until it turned out that the current VB.NET can''t handle array attribute properties.
I think that this is an unnecessary design restriction, and both the VB and C++ teams didn''t follow this. Do you know a way to suggest this to the
"language designers"?

Jens.

--
http://ManagedXLL.net/ | http://jens-thiel.de/ | http://QuantLib.net/
Replace MSDN with my first name when replying to my email address!
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:Oj**************@TK2MSFTNGP10.phx.gbl...
Jens,
我相信这是
语言设计师的一次尝试
Jens,

I believe it''s an attempt on the part of the designers of the language
来强制执行好的设计(想到你什么时候写的?一个值和
to enforce good design (the thinking being when would you write a value and
无法读取它?)。

希望这会有所帮助。

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

Jens Thiel < MS ** @ Thiel.de>在消息中写道
新闻:uX ************** @ tk2msftngp13.phx.gbl ...
not be able to read it?).

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

"Jens Thiel" <MS**@Thiel.de> wrote in message
news:uX**************@tk2msftngp13.phx.gbl...

C#是否有理由要求属性参数(属性)
Hi,

is there a reason for C# to require attribute arguments (properties)



是读写的,而VB和C ++只对setter感到满意?

简化示例:

public sealed class FooAttribute:Attribute
{private string s;
public string Data {set {s =值; } $; $

[Foo(Data =" bar")]在C#中不起作用,但在VB.NET和C ++中起作用。
Jens。

-
http://ManagedXLL.net/ | http://jens-thiel.de/ | http://QuantLib.net/ 在回复我的电子邮件地址时,用我的名字替换MSDN!


to be read-write while VB and C++ are happy with only a setter?

Simplified Example:

public sealed class FooAttribute : Attribute
{
private string s;
public string Data { set { s = value; } };
}
[Foo(Data="bar")] won''t work in C#, but in VB.NET and C++.

Jens.

--
http://ManagedXLL.net/ | http://jens-thiel.de/ | http://QuantLib.net/ Replace MSDN with my first name when replying to my email address!





这篇关于CS0617:读写属性属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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