Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error missing namespace or assembly reference

I am writing the code right, but getting error - missing namespace or assembly reference.Is there something wrong with the code or I am missing something?

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

namespace ConsoleApplication5
{
    class Program
    {
        static void Main(string[] args)
        {
            int i = 0;
            int sum = 0;
            int[] arr = new int[] { 1, 2 };

            do
            {
                {
                    sum += arr[1];
                    Console.WriteLine("Wow");
                    i++;
                }
            }
            while (i < 3);
        }
    }
}

Error is : Error Cannot initialize type 'int' with a collection initializer because it does not implement 'System.Collections.IEnumerable

like image 485
Geek Avatar asked Aug 15 '12 06:08

Geek


People also ask

How do you fix Are you missing an assembly reference?

In order to resolve this error, they have to delete the current reference and re-add the reference.

How do I fix error CS0246?

If you hover your mouse over the red line under GridLayoutGroup (provided you use visual studio as your IDE) then a light bulb should appear. Hover your mouse over the light bulb, you will have an option like "Using UnityEngine. UI" click on it and your problem will be solved.


1 Answers

My namespace ended in Console (i.e. MyProject.Console) which messed up the calls to Console.Write. In this case, either write the fully qualified name System.Console.Write or change the namespace.

like image 174
contactmatt Avatar answered Oct 26 '22 07:10

contactmatt