Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7776739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:57:22+00:00 2026-06-01T17:57:22+00:00

Please be easy on me guys as I’m still learning. The following code: Imports

  • 0

Please be easy on me guys as I’m still learning.

The following code:

Imports System.Console

Module Module1

    Sub Main()
        Dim num As Integer
        Dim name As String

        num = 1
        name = "John"

        WriteLine("Hello, {0}", num)
        WriteLine("Hello, {0}", name)
        WriteLine("Hello, {0}", 1)
        WriteLine("Hello, {0}", "John")
        WriteLine("5 + 5 = {0}", 5 + 5)

        WriteLine()
    End Sub

End Module

has the same output as this code:

Imports System.Console

    Module Module1

        Sub Main()
            Dim num As Integer
            Dim name As String

            num = 1
            name = "John"

            WriteLine("Hello, " & num)
            WriteLine("Hello, " & name)
            WriteLine("Hello, " & 1)
            WriteLine("Hello, " & "John")
            WriteLine("5 + 5 = " & 5 + 5)

            WriteLine()
        End Sub

    End Module

Both output:

Hello, 1
Hello, John
Hello, 1
Hello, John
5 + 5 = 10

I looked everywhere and couldn’t find the answer.
When to use “{0}, {1}, … etc”? and when to use “&”?
Which is better? And why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T17:57:23+00:00Added an answer on June 1, 2026 at 5:57 pm

    What you’re seeing here are two very different expressions that just so happen to evaluate to the same output.

    The & operator in VB.Net is the string concatenation operator. It essentially works by converting both the left and right side of the expression to a String and them adding them together. This means all the below operations are roughly equivalent

    "Hello " & num
    "Hello " & num.ToString()
    "Hello " & CStr(num)
    

    The {0} is a feature of the .Net APIs. It represents a position within a string which will later be replaced with a value. The {0} refers to the first value passed to the function, {1} the second and so on. This means that all the below operations are roughly equivalent

    Console.WriteLine("Hello {0}!", num)
    Console.WriteLine("Hello " & num & "!")
    

    The reason you see the same output is because putting {0} at the end of the string is almost exactly the same as a string concatenation of the 2 values.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please your opinion on the following code. I need to calculate the diff in
Please consider this code: template<typename T> char (&f(T[1]))[1]; template<typename T> char (&f(...))[2]; int main()
Please be easy on me and don't shoot me as I'm still newbie. I'm
I'm very new so just learning, so go easy please! start = int(input('How much
Hi guys this is my first question ever on SO so please go easy
please be easy - first post! Looking to modify the following script: http://jonraasch.com/blog/a-simple-jquery-slideshow Love
I'm fairly new to this so please go easy on me if this is
I'm very new to Ruby on Rails so please go easy! I've uploaded the
Could someone please recommend a simple (as in very easy to understand) charting library
I need some with help with PowerShell, please. It should be pretty easy: I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.