What is XML literal?
"XML Literal" is a new feature introduced in vb.net 9.0 to build XML objects. VB.net with such artifacts, now it is the C # Programmer's envy. Of course this article does not say how to use XML literal, for more information on this new feature can be found in MSDN:
Http://msdn.microsoft.com/en-us/library/bb384629.aspx
With XML literal, how do we use it to solve the problem of multi-line strings in vb.net? See Example:
Dim SourceText as String = <string> Imports Microsoft.VisualBasic Imports System Imports System.Collections Imports Microsoft.Win32 Imports System.Linq Imports System.Text Imports Roslyn.compilers Imports System.ComponentModel Imports System.Runtime.CompilerServices Imports Roslyn.Compilers.VisualBasic Namespace HelloWorld Module program Sub Main (args as String ()) Console.WriteLine ("Hello, world!") End Sub End Module end Namespace </string>
Compare the previous code, there is no heart to say "I" two words?
The obvious change is that there is no explicit type declaration of as string, which is then called later. The Value property to determine that the variable is indeed a string. In fact, compared to the above code, these two pieces of code at compile, run time and no difference. Maybe the second one is more beautiful?
What's more, we can also write:
Dim contact2 = <contact> <name>patrick hines</name> <%= from P in PhoneNumbers2 Select <phone type=<%= p.type%>><%= p.number%></phone> %> </contact>
So do not laugh at the vb.net can not be convenient to write a string!!
In addition, the vb.net can not be more than a line of statements written in one line I also want to say, this before the VB6 of the product you do not know? And look at:
Dim A, b as string:a = 1:B = "ABC"
Let C # envy the VB.net property