Private Function isDuplicateField(ByRef existMetaItems As CMetas(), ByVal currentFieldChName As String, ByVal currentVal As String) Dim isExist As Boolean = False For Each metaItem As CMetas In existMetaItems If metaItem Is Nothing Then Continue For End If If metaItem.MetaType = currentFieldChName Then If (Not String.IsNullOrEmpty(currentVal)) And String.IsNullOrEmpty(metaItem.MetaValue) Then metaItem.MetaValue = currentVal End If isExist = True Exit For End If Next Return isExist End Function 转换c#代码
时间: 2024-02-10 10:18:53 浏览: 102
asp中Byval与Byref的区别
以下是 C# 版本的代码:
```
private bool IsDuplicateField(ref CMetas[] existMetaItems, string currentFieldChName, string currentVal)
{
bool isExist = false;
foreach (CMetas metaItem in existMetaItems)
{
if (metaItem == null)
{
continue;
}
if (metaItem.MetaType == currentFieldChName)
{
if (!string.IsNullOrEmpty(currentVal) && string.IsNullOrEmpty(metaItem.MetaValue))
{
metaItem.MetaValue = currentVal;
}
isExist = true;
break;
}
}
return isExist;
}
```
注意到 C# 中的数组参数需要带上方括号,即 `CMetas[]`。另外,C# 中的字符串类型是 `string` 而不是 `String`,但在实际使用时两者是等价的。
阅读全文