我怎样才能将此代码转换为VB.net
public void SetBooks(IEnumerable<Book> books) { if (books == null) throw new ArgumentNullException("books"); new System.Xml.Linq.XDocument(books).Save(_filename); }
在http://converter.telerik.com/它说:
Public Sub SetBooks(books As IEnumerable(Of Book)) If books Is nothing Then Throw New ArgumentNullException("books") End If New System.Xml.Linq.XDocument(books).Save(_filename) End Sub
这种情况的关键字是什么,我在Google上搜索但没有结果.
解决方法
您无法初始化对象并在VB.NET中的一个语句中使用它(而不是C#).你需要两个:
Dim doc = New System.Xml.Linq.XDocument(books) doc.Save(_filename)
在C#中构造函数returns the instance of the created object,在VB.NET中没有.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。