Re: Debug.WriteLine syntax
1) you posted in the wrong forum... I'll ask the mods to move it.
2) Did you look at the documentation?
.WriteLine uses a format string, like what String.Format uses. {0} is a place holder. It tells the formatter that the first item in the parameter array is to go into that spot. {1} Means the next item goes in that spot and so on. You can also apply other formatting to the objects depending on what they are, for example, if it is a number, you can indicate if decimals are to be displayed, how many, currency symbol, and so on.
-tg
Re: Debug.WriteLine syntax
The Code for the example is in language Visual Basic.NET from MSN:
https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx
Thank you for your answer.:wave:
Re: Debug.WriteLine syntax
This isn't a special "debug syntax" but instead a more general "string formatting" syntax that many parts of the .NET framework use. I did a sort of mini-tutorial in another thread, but it wasn't focused on explaining the syntax.
Console.WriteLine(), Debug.WriteLine(), and String.Format() use a syntax MS calls "composite formatting" to help you format strings. By way of quick example, these two lines do the same thing:
Code:
Dim example As String = "Hello " & someVariable & "!"
Dim example As String = String.Format("Hello {0}!", someVariable")
To make a "format string", you type out a normal string. In places where you want to substitute a variable, you insert an {n} symbol, that is, a curly brace, a number, and a closing curly brace. The numbers should start at 0 and get bigger as the string goes on.
Any method that expects a format string also takes parameters at the end. Parameters are substituted into the string, in order, replacing the {n} symbols you made.
So if you need to put in two symbols:
Code:
Console.WriteLine("Hello, {0} {1}!", firstName, lastName)
You can also repeat them:
Code:
Console.WriteLine("Hello, {0}{1}{0}{2}", Environment.NewLine, firstName, lastName)
There are some other neat things you can do, but you can read about them in depth at your leisure.
Re: Debug.WriteLine syntax
Now I get it !!!. Thank you.:wave: