设定......我用什么。 [英] Get set... what do i use .

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

问题描述

如果我有这个属性


Dim m_name为字符串


属性名称()为字符串

获取

返回m_name

end获取

设置(byval Value as string)

m_name = Value

结束集

结束财产

在我的代码中我必须使用m_name或名称?

If i have this property

Dim m_name as string

Property name() as string
Get
return m_name
end Get
Set (byval Value as string)
m_name = Value
End set
End property
In my code i have to use m_name or name ?

推荐答案

您将在具有此属性的类中使用m_name。当设置

或从课堂外获取名称属性时,您将使用名称。


" ucasesoftware" < UC *********** @ hotmail.fr>在消息中写道

news:11 ********************** @ o13g2000cwo.googlegr oups.com ...
You would use m_name inside the class that has this property. When setting
or getting the name property from outside the class, you would use name.

"ucasesoftware" <uc***********@hotmail.fr> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
如果我有这个属性

Dim m_name为字符串

属性名称()为字符串
获取
返回m_name
结束获取
设置(byval Value as string)
m_name = Value
结束集
结束属性

在我的代码中我必须使用m_name或name ?
If i have this property

Dim m_name as string

Property name() as string
Get
return m_name
end Get
Set (byval Value as string)
m_name = Value
End set
End property
In my code i have to use m_name or name ?



ok thx


另一个问题:


在类方法中...我可以使用sql连接吗?或者......它不是

好​​吗?


公共类monAgenda

Dim m_agendaGuid作为Guid

物业议程指南()作为Guid

获取

返回m_agendaGuid

结束获取

Set(ByVal价值作为指导)

m_agendaGuid =价值

结束集

结束物业


Dim m_entrepriseGuid As Guid

Property entrepriseGuid()作为Guid

获取

返回m_entrepriseGuid

结束获取

套装(ByVal价值作为指导)

m_entrepriseGuid =价值

结束套件

结束物业

Dim m_salarieGuid作为Guid

物业salarieGuid()作为Guid

获取

返回m_salarieGuid

结束获取

套装(ByVal价值作为指导)

m_salarieGuid =价值

结束套件

结束物业

昏暗m_agendaNom As String

Property agendaNom()As String

获取

返回m_agendaNom

结束获取

设置(ByVal值为字符串)

m_agendaNom =价值

结束集

结束财产


Dim m_firstHour As String

Property firstHour()As String

Get

返回m_firstHour

结束获取

套装(ByVal价值为字符串)

m_firstHour =价值

结束套件

结束物业


Dim m_workHourBegin As String

物业workHourBegin()As String

获取

返回m_workHourBegin

结束获取

设置(ByVal值为字符串)

m_workHourBegin = Value

结束集

结束物业


Dim m_workHourEnd As String

物业workHourEnd()作为字符串

获取

返回m_workHourEnd

结束获取

设置(ByVal值为字符串)

m_workHourEnd = Value

结束集

结束物业


Dim m_hourResolution As String

物业h ourResolution()As String

获取

返回m_hourResolution

结束获取

设置(ByVal值为字符串)

m_hourResolution =价值

结束集

结束物业

Dim m_isRdv作为布尔值

物业isRdv()As布局

获取

返回m_isRdv

结束获取

Set(ByVal Value As Boolean)

m_isRdv =价值

结束套件

结束物业


Dim m_template As String

物业模板()作为字符串

获取

返回m_template

结束获取

Set( ByVal Value As String)

m_template =价值

结束集

结束物业

公共职能议程员(ByVal salarieGuid)作为Guid)作为字符串

尝试

将myConnexion变为新的SqlConnection

ouvreConnexion(myConnexion)

Dim cmd As SqlCommand

cmd =新的SqlCommand(" SELECT salarie.prenom +'''' +

salarie.nom +''(''+ entreprise.raisonSociale +'')''AS nomComplet from

salarie INNER JOIN entreprise on salarie.entrepriseGuid =
entreprise.entrepriseGuid &安培; salarieGuid.ToString

& "''',myConnexion)

返回cmd.ExecuteScalar

Catch ex As Exception

monErreur(ex)

结束尝试

结束功能


结束班

ok thx

One other question :

in class method... can i use sql connexion like that ? or... it''s not
good ?

Public Class monAgenda
Dim m_agendaGuid As Guid
Property agendaGuid() As Guid
Get
Return m_agendaGuid
End Get
Set(ByVal Value As Guid)
m_agendaGuid = Value
End Set
End Property

Dim m_entrepriseGuid As Guid
Property entrepriseGuid() As Guid
Get
Return m_entrepriseGuid
End Get
Set(ByVal Value As Guid)
m_entrepriseGuid = Value
End Set
End Property
Dim m_salarieGuid As Guid
Property salarieGuid() As Guid
Get
Return m_salarieGuid
End Get
Set(ByVal Value As Guid)
m_salarieGuid = Value
End Set
End Property
Dim m_agendaNom As String
Property agendaNom() As String
Get
Return m_agendaNom
End Get
Set(ByVal Value As String)
m_agendaNom = Value
End Set
End Property

Dim m_firstHour As String
Property firstHour() As String
Get
Return m_firstHour
End Get
Set(ByVal Value As String)
m_firstHour = Value
End Set
End Property

Dim m_workHourBegin As String
Property workHourBegin() As String
Get
Return m_workHourBegin
End Get
Set(ByVal Value As String)
m_workHourBegin = Value
End Set
End Property

Dim m_workHourEnd As String
Property workHourEnd() As String
Get
Return m_workHourEnd
End Get
Set(ByVal Value As String)
m_workHourEnd = Value
End Set
End Property

Dim m_hourResolution As String
Property hourResolution() As String
Get
Return m_hourResolution
End Get
Set(ByVal Value As String)
m_hourResolution = Value
End Set
End Property
Dim m_isRdv As Boolean
Property isRdv() As Boolean
Get
Return m_isRdv
End Get
Set(ByVal Value As Boolean)
m_isRdv = Value
End Set
End Property

Dim m_template As String
Property template() As String
Get
Return m_template
End Get
Set(ByVal Value As String)
m_template = Value
End Set
End Property
Public Function agendaOwner(ByVal salarieGuid As Guid) As String
Try
Dim myConnexion As New SqlConnection
ouvreConnexion(myConnexion)
Dim cmd As SqlCommand
cmd = New SqlCommand("SELECT salarie.prenom + '' '' +
salarie.nom + '' ('' + entreprise.raisonSociale + '')'' AS nomComplet FROM
salarie INNER JOIN entreprise ON salarie.entrepriseGuid =
entreprise.entrepriseGuid where salarieGuid = ''" & salarieGuid.ToString
& "''", myConnexion)
Return cmd.ExecuteScalar
Catch ex As Exception
monErreur(ex)
End Try
End Function

End Class


"特里奥尔森 <到****** @ hotmail.com> schrieb:
"Terry Olsen" <to******@hotmail.com> schrieb:
您可以在具有此属性的类中使用m_name。当从课外设置或获取名称属性时,您将使用
名称。
You would use m_name inside the class that has this property. When
setting or getting the name property from outside the class, you would use
name.




个人偏好。我更喜欢使用私有变量上的属性,

,因为这会增加验证的好处,特别是在为物业分配

a新值时。


-

MS Herfried K. Wagner

MVP< URL:http://dotnet.mvps.org/>

VB< URL:http://classicvb.org/petition/>



Personal preference. I prefer using the property over the private variable,
because this would add the benefit of validation, especially when assigning
a new value to the property.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>


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

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