[英]Assignment as method argument, how to do that in VB.NET?
我正在将应用程序转换为VB.Net,但我不知道如何将下面的行转换为VB.Net。 此应用程序引用了Sharepoint,因此该对象引用了Sharepoint组件。
context.Load(item = listFields.GetItemById(listItemId);
有什么建议如何将其转换为vb.net吗?
我不喜欢这种C#方式来分配变量并直接使用它。 我还将在C#的两行中编写它:
item = listFields.GetItemById(listItemId);
context.Load(item);
现在清楚了吗?
当我发现直接使用赋值表达式的返回值很有用时(VB.NET不支持)有一个例外:
string line;
using(var reader = new StreamReader("Path"))
while((line = reader.ReadLine()) != null)
{
// ...
}
在VB.NET中,您需要这样的丑陋代码:
Using reader = New StreamReader("Path")
Do
Dim line As String = reader.ReadLine()
If line Is Nothing Then Exit Do
' ... '
Loop
End Using
这就是为什么在大多数情况下我更喜欢File
类的原因,例如:
For Each line As String In File.ReadLines("Path")
' ... '
Next
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.