Hi
I am beginner in C#.please tell me what is problem in this code :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {

            string[] firstName={};
            string[] lastName={};

            Console.WriteLine("Please type your firstName : ");

            for (int i = 0; i < 10; i++)
            {
                firstName[i] = Console.ReadLine();
            }

            Console.WriteLine("Please type your lastName : ");

            for (int j = 0; j < 10; j++)
            {
                lastName[j] = Console.ReadLine();
            }

            for (int k = 0; k < 10; k++)
            {
                Console.WriteLine(k + " " + firstName[k].ToUpper() + " " + lastName[k].ToUpper());
            }

            Console.ReadLine();
        }
    }
}

if you can, please repair it for me .

Edited 3 Years Ago by Dani: Formatting fixed

firstname and lastname must be of type string, not of type array of string.
Now you are reding in 10 first and 10 lastnames.

Edited 5 Years Ago by ddanbe: n/a

I want to give 10 name and 10 family and print them, How can I do this work with my code that come in first post ?

These lines

string[] firstName={};
string[] lastName={};

declare them as zero length arrays. You then try to insert 10 items into these arrays (which, again, have zero length). You need to declare them as arrays of length 10:

string[] firstName = new String[10];
string[] lastName = new String[10];
This article has been dead for over six months. Start a new discussion instead.