0

when i execute the below progam i am getting this errror type or namespace definition, or end-of-file expected in c#

using System;


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

	string[] colorList =new string[10];

                    colorList[0] = "sunday";
                    colorList[1] = "monday";
                    colorList[2] = "tuesday";
                    colorList[3] = "wednesday";
                    colorList[4] = "thursday";
                    colorList[5] = "friday";
                   colorList[6] = "saturday";
                       

             		 for( int  i =0;  i < 10;  i++)
		{

		Console.WriteLine("Color is: {0}", colorList[i]);
	   	}
                
	                      Console.ReadLine();
	           
                    }

}
3
Contributors
3
Replies
5
Views
6 Years
Discussion Span
Last Post by james6754
0

>type or namespace definition, or end-of-file expected in c#

Error causes when a source code file does not have a matching set of braces.

using System;


class Program
{
    public static void Main(string[] args)
    {
        string[] colorList = new string[10];

        colorList[0] = "sunday";
        colorList[1] = "monday";
        colorList[2] = "tuesday";
        colorList[3] = "wednesday";
        colorList[4] = "thursday";
        colorList[5] = "friday";
        colorList[6] = "saturday";

        for (int i = 0; i < 10; i++)
        {

            Console.WriteLine("Color is: {0}", colorList[i]);
        }
        Console.ReadLine();
    }
}
0

Hi mate...code seems to be fine...just put a curly brace to close the namespace and you should be good to go....

0

although because you have declared 10 items in your array....

your going to get it list the days "colour is -whatever-" then your going to have another 3 lines that just say "colour is -blank-", that is not supposed to sound condescending in any way....

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.