Call instance method inline after New statement
vb.net
Solution
You cannot initialize an object and use it in one statement in VB.NET (as opposed to C#). You need two:
Dim doc = New System.Xml.Linq.XDocument(books)
doc.Save(_filename)
In C# the constructor returns the instance of the created object, in VB.NET not.
Problem
How can i convert this code to VB.net ``` public void SetBooks(IEnumerable<Book> books) { if (books == null) throw new ArgumentNullException("books"); new System.Xml.Linq.XDocument(books).Save(_filename); } ``` in http://converter.telerik.com/ it says: ``` 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 ``` But visual studio says "Syntax error." because of "New" What is the keyword for this situation, i searched on Google but no result.