[英]What's the difference between myObject.MyField and myObject.MyField() in VB.net?
I stumbled upon this issue: 我偶然发现了这个问题:
myObject
's class has a public field MyField
which type is Decimal?
myObject
的类具有一个公共字段MyField
,哪种类型为Decimal?
I accidentally access the field as if it were a property with this code: 我不小心访问该字段,就好像它是具有以下代码的属性:
myObject.MyField()
instead of 代替
myObject.MyField
And I got the following error from the compiler: Structure 'Decimal?' cannot be indexed because it has no default property
而且我从编译器中收到以下错误:
Structure 'Decimal?' cannot be indexed because it has no default property
Structure 'Decimal?' cannot be indexed because it has no default property
Documentation on this error on MSND is very short and I just don't understand what it means. 有关此MSND错误的文档非常简短,我只是不明白这意味着什么。
Q: What's the meaning of myObject.MyField()
if it has one, and why can't I use it on my field if so? 问:如果
myObject.MyField()
有一个,它是什么意思,为什么我不能在我的字段上使用它?
Note: my problem is now solved but I would like to understand... 注意:我的问题现在已经解决,但我想了解...
You access elements of an array using ()
in VB.NET. 您可以在VB.NET中使用
()
访问数组的元素。 The error message is telling you Structure 'Decimal?' cannot be indexed
错误消息告诉您
Structure 'Decimal?' cannot be indexed
Structure 'Decimal?' cannot be indexed
because it can't. Structure 'Decimal?' cannot be indexed
因为它无法建立Structure 'Decimal?' cannot be indexed
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.