[英]DebuggerStepThrough attribute equivalent for properties?
DebuggerStepThrough
屬性指示VS調試器單步執行代碼,而不是單步執行代碼。
我的問題是,是否有與該屬性等效的屬性可用於Property
成員?,因為我的屬性的設置器會引發異常,並且我不想在發生這種情況時中斷設置器的代碼塊。
我知道一種解決方案是將setter的代碼移動到單個方法,然后將DebuggerStepThrough
屬性設置為該方法,但是我只是在尋求一種可能的替代方法,即應用另一個屬性而不是移動代碼。
實際上,您可以直接將此屬性應用於getter和setter。
Dim firstName, lastName As String
Property fullName() As String
<DebuggerStepThrough>
Get
If lastName = "" Then
Return firstName
Else
Return firstName & " " & lastName
End If
End Get
<DebuggerStepThrough>
Set(ByVal Value As String)
Dim space As Integer = Value.IndexOf(" ")
If space < 0 Then
firstName = Value
lastName = ""
Else
firstName = Value.Substring(0, space)
lastName = Value.Substring(space + 1)
End If
End Set
End Property
對於C#,這是相同的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.