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 .

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

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];
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.