Results 1 to 9 of 9

Threaded View

  1. #1
    Join Date
    Sep 2016
    Posts
    14

    C# basic question

    Grettings,

    Could someone please help me understand this very basic syntax issue regarding C# please?

    Here is some ridiculously basic C# code:

    Code:
    using System;
    using System.Collections.Generic;
    
    class Program
    {
        static void Main()
        {
            int myIndex = 0;
    
            while (myIndex < 10)
            {
                Console.WriteLine("myIndex value is: " + myIndex);
                myIndex++;
            }
    
            Console.ReadKey();
        }
    }
    In one of the C# tutorial videos I noticed that the main line whithin the while loop was put in the following way:

    Code:
    Console.WriteLine("myIndex value is: {0}", myIndex);
    and the code worked.

    How does this work? What is this {0} ?? Please help in understanding.
    Last edited by goldeen; 09-24-2016 at 03:17 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •