vb.net syntax question

I ran into the following line of code in a project:
Dim X As System.Xml.XmlDocument : X = New System.Xml.XmlDocument()

what is the ":" being used for here?
dhenderson12Asked:
Who is Participating?
 
Shaun KlineConnect With a Mentor Lead Software EngineerCommented:
The colon acts like a statement separator.
The code could be rewritten like below and produce the same effect:
Dim X As System.Xml.XmlDocument
X = New System.Xml.XmlDocument()

Open in new window

0
 
Trideep PatelProject LeadCommented:
":" is used to write two statements in one line.
Like below

Dim i As Integer : Dim j As Integer : Dim k As Integer

Here once can write three separate lines
Dim i As Integer
Dim j As Integer
Dim k As Integer
0
 
dhenderson12Author Commented:
thanks, guys.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
käµfm³d 👽Commented:
Personally, I just combine all of that into one statement--no colon needed:

Dim X As New System.Xml.XmlDocument()

Anything else is just a waste of keystrokes.
0
 
dhenderson12Author Commented:
sorry for the delay
0
 
dhenderson12Author Commented:
thanks
0
All Courses

From novice to tech pro — start learning today.