none
Array.Reverse RRS feed

  • Question

  • why when i type Array.Reverse i get an error message The type or namespace name 'Reverse' does not exist in the namespace 'Array' (are you missing an assembly reference?)
    Monday, June 29, 2015 7:30 AM

Answers

  • "The type or namespace name 'Reverse' does not exist in the namespace 'Array' "

    The last part of the error message indicates that you have created a namespace named "Array" in your project (probably you created a project named Array) and because of that the compiler looks for a type (or another namespace) called "Reverse" in the "Array" namespace instead of looking for the "Reverse" method of the "Array" type.

    You can still access the static members of the "Array" by using its full name:

    System.Array.Reverse(...);

    Next time try to pick a project name that's less likely to conflict with a common type name. For example - ArrayExercise, ArrayTest, ArraySample etc.

    Monday, June 29, 2015 7:45 AM
    Moderator
  • There is insufficient information in your question to work out why you are seeing this error message.

    If I start up a new console app.

    I change Main:

    static void Main(string[] args)
    {
         int[] myarray = new int[] {1,2,3};
         Array.Reverse(myarray);
    }

    That works fine.

    Your problem is either you're doing something wrong or your visual studio install is broke.

    If the above code doesn't work for you in a new console app then I suggest you install > refresh.


    Hope that helps.

    Technet articles: WPF: Change Tracking; All my Technet Articles


    Monday, June 29, 2015 7:47 AM
    Moderator

All replies

  • did you include :

    using System.Collections.Generic;
    // or
    using System.Collections;

    at the top?


    Hope it helps. Spiri

    Monday, June 29, 2015 7:42 AM
  • "The type or namespace name 'Reverse' does not exist in the namespace 'Array' "

    The last part of the error message indicates that you have created a namespace named "Array" in your project (probably you created a project named Array) and because of that the compiler looks for a type (or another namespace) called "Reverse" in the "Array" namespace instead of looking for the "Reverse" method of the "Array" type.

    You can still access the static members of the "Array" by using its full name:

    System.Array.Reverse(...);

    Next time try to pick a project name that's less likely to conflict with a common type name. For example - ArrayExercise, ArrayTest, ArraySample etc.

    Monday, June 29, 2015 7:45 AM
    Moderator
  • There is insufficient information in your question to work out why you are seeing this error message.

    If I start up a new console app.

    I change Main:

    static void Main(string[] args)
    {
         int[] myarray = new int[] {1,2,3};
         Array.Reverse(myarray);
    }

    That works fine.

    Your problem is either you're doing something wrong or your visual studio install is broke.

    If the above code doesn't work for you in a new console app then I suggest you install > refresh.


    Hope that helps.

    Technet articles: WPF: Change Tracking; All my Technet Articles


    Monday, June 29, 2015 7:47 AM
    Moderator
  • I would suggest you start a new program to test the code here:

    https://msdn.microsoft.com/en-us/library/d3877932(v=vs.110).aspx

    If everything is running fine then it should be your namespace or variable name issues.

    chanmm


    chanmm

    Monday, June 29, 2015 11:22 AM