錯誤:不能相互重載,因爲它們只有可選參數不同。爲什麼這是一個不適當的超載?
一種方法有3個參數,另一種有4個參數。我錯過了什麼?
Protected Overloads Function updateResxNodes(ByVal keyCtrl As String, ByVal newValue As String, Optional ByVal newComment As String = "") As List(Of ResXDataNode)
Dim resxNodesList As List(Of ResXDataNode) = getResourceData()
For i As Integer = 0 To resxNodesList.Count - 1
If resxNodesList.Item(i).Name = keyCtrl Then
Dim name As String = resxNodesList.Item(i).Name
Dim comment As String = resxNodesList.Item(i).Comment
Dim newResxNode As ResXDataNode = New ResXDataNode(name, newValue)
newResxNode.Comment = comment
resxNodesList.RemoveAt(i)
resxNodesList.Add(newResxNode)
Exit For
End If
Next
Return resxNodesList
End Function
Protected Overloads Function updateResxNodes(ByVal keyCtrl As String, ByVal newName As String, ByVal newValue As String, Optional ByVal newComment As String = "") As List(Of ResXDataNode)
Dim resxNodesList As List(Of ResXDataNode) = getResourceData()
For i As Integer = 0 To resxNodesList.Count - 1
If resxNodesList.Item(i).Name = keyCtrl Then
Dim name As String = resxNodesList.Item(i).Name
Dim comment As String = resxNodesList.Item(i).Comment
Dim newResxNode As ResXDataNode = New ResXDataNode(name, newValue)
newResxNode.Comment = comment
resxNodesList.RemoveAt(i)
resxNodesList.Add(newResxNode)
Exit For
End If
Next
Return resxNodesList
End Function
啊。我懂了。謝謝。 – dotnetN00b