没问题 [英] Is Nothing problem

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

问题描述

您好,


我有一个通用列表如下:

Dim rows As New Generic.List(Of row)


现在我有一行:

Dim myRow作为行


我试图检查,在我的代码中,如果行是没有:

如果myRow什么都没有那么

....

结束如果


我得到错误:

" Is"需要具有引用类型的操作数,但是这个操作数有一个Rows的值。




我知道我做错了什么?


无论如何,这是我的行定义及其依赖关系:


''行

公共结构行


'' - [属性] ----


''单元格

私有_Cells As Generic.List(Of Cell)

Public Property Cells()As Generic.List(Of Cell)

获取

返回_Cells

结束获取

设置(ByVal Cells As Generic.List(Of Cell))

_Cells = Cells

结束集

结束属性''单元格


''名称

私有_Name为字符串

公共属性名称()为字符串

获取

返回_Name

结束获取

设置(ByVal名称为字符串)

_Name =姓名

结束集

结束物业''名称


结构结构''行

''细胞

公共结构细胞


'' - [属性] ----


''内容

私有_Content As Object

公共财产内容()作为对象

获取

返回_内容

结束获取

设置(ByVal内容为对象)

_Content = Content

结束集

结束物业''内容


''文化

私人_文化作为CultureInfo

公共财产文化()作为CultureInfo

获取

返回_Culture

结束获取

Set(ByVal Culture As CultureInfo)

_Culture =文化

结束集

结束物业''文化


结束结构''细胞


谢谢,

Miguel

Hello,

I have a generic list as follows:
Dim rows As New Generic.List(Of row)

Now I have a row:
Dim myRow As row

I tried to check, further in my code, if the row is nothing:
If myRow Is Nothing Then
....
End If

I get an error:
"Is" requires operand that have reference types but this operand has
the value of Rows.Row"

Any idea what I am doing wrong?

Anyway, this is my row definition and its dependencies:

'' Row
Public Structure Row

'' -- [Properties] ----

'' Cells
Private _Cells As Generic.List(Of Cell)
Public Property Cells() As Generic.List(Of Cell)
Get
Return _Cells
End Get
Set(ByVal Cells As Generic.List(Of Cell))
_Cells = Cells
End Set
End Property '' Cells

'' Name
Private _Name As String
Public Property Name() As String
Get
Return _Name
End Get
Set(ByVal Name As String)
_Name = Name
End Set
End Property '' Name

End Structure '' Row

'' Cell
Public Structure Cell

'' -- [Properties] ----

'' Content
Private _Content As Object
Public Property Content() As Object
Get
Return _Content
End Get
Set(ByVal Content As Object)
_Content = Content
End Set
End Property '' Content

'' Culture
Private _Culture As CultureInfo
Public Property Culture() As CultureInfo
Get
Return _Culture
End Get
Set(ByVal Culture As CultureInfo)
_Culture = Culture
End Set
End Property '' Culture

End Structure '' Cell

Thanks,
Miguel

推荐答案

结构是值类型,因此您可以使用= Nothing。

-

David Anton
www.tangiblesoftwaresolutions.com

即时C#:VB转换为C#转换器

即时VB:C#到VB转换器

即时C ++:C#/ VB到C ++转换器

即时Python:C#/ VB到Python转换器
" shapper"写道:
Structures are value types, so you can use "= Nothing".
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: C#/VB to Python converter
"shapper" wrote:

你好,


我有一个通用列表如下:

昏暗的行As New Generic.List(排)


现在我有一排:

Dim myRow As row


我试着在我的代码中进一步查看行是否为空:

如果myRow什么都没有那么

....

结束如果


我收到错误:

" Is"需要具有引用类型的操作数,但是这个操作数有一个Rows的值。




我知道我做错了什么?


无论如何,这是我的行定义及其依赖关系:


''行

公共结构行


'' - [属性] ----


''单元格

私有_Cells As Generic.List(Of Cell)

Public Property Cells()As Generic.List(Of Cell)

获取

返回_Cells

结束获取

设置(ByVal Cells As Generic.List(Of Cell))

_Cells = Cells

结束集

结束属性''单元格


''名称

私有_Name为字符串

公共属性名称()为字符串

获取

返回_Name

结束获取

设置(ByVal名称A s String)

_Name =姓名

结束集

结束物业''名称


结束结构''行


''单元格

公共结构单元


'' - [属性] - ---


''内容

私有_Content As Object

公共财产内容()作为对象

获取

返回_内容

结束获取

设置(ByVal内容为对象)

_Content = Content

结束套装

结束物业''内容


''文化

私人_文化作为CultureInfo

公共物业文化()作为CultureInfo

获取

返回_Culture

结束获取

套装(ByVal Culture As CultureInfo)

_Culture = Culture

结束集

结束物业''文化


结束结构''单元格


谢谢,

Miguel

Hello,

I have a generic list as follows:
Dim rows As New Generic.List(Of row)

Now I have a row:
Dim myRow As row

I tried to check, further in my code, if the row is nothing:
If myRow Is Nothing Then
....
End If

I get an error:
"Is" requires operand that have reference types but this operand has
the value of Rows.Row"

Any idea what I am doing wrong?

Anyway, this is my row definition and its dependencies:

'' Row
Public Structure Row

'' -- [Properties] ----

'' Cells
Private _Cells As Generic.List(Of Cell)
Public Property Cells() As Generic.List(Of Cell)
Get
Return _Cells
End Get
Set(ByVal Cells As Generic.List(Of Cell))
_Cells = Cells
End Set
End Property '' Cells

'' Name
Private _Name As String
Public Property Name() As String
Get
Return _Name
End Get
Set(ByVal Name As String)
_Name = Name
End Set
End Property '' Name

End Structure '' Row

'' Cell
Public Structure Cell

'' -- [Properties] ----

'' Content
Private _Content As Object
Public Property Content() As Object
Get
Return _Content
End Get
Set(ByVal Content As Object)
_Content = Content
End Set
End Property '' Content

'' Culture
Private _Culture As CultureInfo
Public Property Culture() As CultureInfo
Get
Return _Culture
End Get
Set(ByVal Culture As CultureInfo)
_Culture = Culture
End Set
End Property '' Culture

End Structure '' Cell

Thanks,
Miguel


" shapper" < md ***** @ gmail.com写信息

news:11 ********************** @ n33g2000cwc。 googlegr oups.com ...
"shapper" <md*****@gmail.comwrote in message
news:11**********************@n33g2000cwc.googlegr oups.com...

如果myRow为Nothing那么
If myRow Is Nothing Then



如果myRow = Nothing Then

If myRow = Nothing Then


实际上,= Nothing除非你的结构中超过''=''运算符

,否则不会工作。

-

David Anton
www.tangiblesoftwaresolutions.com

即时C#:VB到C#转换器

即时VB:C#到VB转换器

即时C ++:C#/ VB到C ++转换器

即时Python:C#/ VB到Python转换器

" shapper"写道:
Actually, "= Nothing" won''t work unless you have overloaded the ''='' operator
in your structure.
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: C#/VB to Python converter
"shapper" wrote:

你好,


我有一个通用列表如下:

昏暗的行As New Generic.List(排)


现在我有一排:

Dim myRow As row


我试着在我的代码中进一步查看行是否为空:

如果myRow什么都没有那么

....

结束如果


我收到错误:

" Is"需要具有引用类型的操作数,但是这个操作数有一个Rows的值。




我知道我做错了什么?


无论如何,这是我的行定义及其依赖关系:


''行

公共结构行


'' - [属性] ----


''单元格

私有_Cells As Generic.List(Of Cell)

Public Property Cells()As Generic.List(Of Cell)

获取

返回_Cells

结束获取

设置(ByVal Cells As Generic.List(Of Cell))

_Cells = Cells

结束集

结束属性''单元格


''名称

私有_Name为字符串

公共属性名称()为字符串

获取

返回_Name

结束获取

设置(ByVal名称A s String)

_Name =姓名

结束集

结束物业''名称


结束结构''行


''单元格

公共结构单元


'' - [属性] - ---


''内容

私有_Content As Object

公共财产内容()作为对象

获取

返回_内容

结束获取

设置(ByVal内容为对象)

_Content = Content

结束套装

结束物业''内容


''文化

私人_文化作为CultureInfo

公共物业文化()作为CultureInfo

获取

返回_Culture

结束获取

套装(ByVal Culture As CultureInfo)

_Culture = Culture

结束集

结束物业''文化


结束结构''单元格


谢谢,

Miguel

Hello,

I have a generic list as follows:
Dim rows As New Generic.List(Of row)

Now I have a row:
Dim myRow As row

I tried to check, further in my code, if the row is nothing:
If myRow Is Nothing Then
....
End If

I get an error:
"Is" requires operand that have reference types but this operand has
the value of Rows.Row"

Any idea what I am doing wrong?

Anyway, this is my row definition and its dependencies:

'' Row
Public Structure Row

'' -- [Properties] ----

'' Cells
Private _Cells As Generic.List(Of Cell)
Public Property Cells() As Generic.List(Of Cell)
Get
Return _Cells
End Get
Set(ByVal Cells As Generic.List(Of Cell))
_Cells = Cells
End Set
End Property '' Cells

'' Name
Private _Name As String
Public Property Name() As String
Get
Return _Name
End Get
Set(ByVal Name As String)
_Name = Name
End Set
End Property '' Name

End Structure '' Row

'' Cell
Public Structure Cell

'' -- [Properties] ----

'' Content
Private _Content As Object
Public Property Content() As Object
Get
Return _Content
End Get
Set(ByVal Content As Object)
_Content = Content
End Set
End Property '' Content

'' Culture
Private _Culture As CultureInfo
Public Property Culture() As CultureInfo
Get
Return _Culture
End Get
Set(ByVal Culture As CultureInfo)
_Culture = Culture
End Set
End Property '' Culture

End Structure '' Cell

Thanks,
Miguel


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

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