Click here to Skip to main content
16,012,468 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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?)"
Posted
Comments
[no name] 29-Jun-15 14:29pm    
Since we can't see your code or anything as a guess, it might be that you are missing an assembly reference.
Suvendu Shekhar Giri 29-Jun-15 14:48pm    
Make sure that you have added following using directive.
using System;
Or you can write like-
System.Array.Reverse
Matt T Heffron 29-Jun-15 14:56pm    
Array is in the System namespace, so... are you missing a
using System;
??
LLLLGGGG 29-Jun-15 15:07pm    
To be sure: If you are using VS, put your mouse cursor on the line of code underlined: you should see a small, red rectangle. Click on it and choose the best workaround for the error.

LG
Suvendu Shekhar Giri 30-Jun-15 3:07am    
It's very unlikely but can check once whether your project have a reference to mscorlib.dll or not?

 
Share this answer
 
You need this at the top of your page

using System.Linq;


This is .net 101, you should go through a book on .net and learn the fundamentals.
 
Share this answer
 
Comments
Suvendu Shekhar Giri 29-Jun-15 14:39pm    
System.Linq? Why?
Member 11800973 30-Jun-15 0:58am    
I have it on top and I'm still getting that error message
Matt T Heffron 1-Jul-15 18:59pm    
Array.Reverse() is in the System namespace, not System.Linq
"The type or namespace name 'Reverse' does not exist in the namespace 'Array' (are you missing an assembly reference?)"

If it considers Array as a namespace qualification, it means you did not import the System namespace.

Just place the line
C#
using System;

at the top of your code file.

Or use a plain qualification:
C#
System.Array.Reverse(myArray);


There is also a Reverse extension method defined in System.Linq namespace, but it acts differently: the former is a void method which acts directly on the array which is passed to it as a parameter, whereas the latter returns a IEnumerable<TSource> that you have to assign to your variable. This way:
C#
using System.Linq;
int[] myArray = new int[] { 1, 2, 3 };
myArray = myArray.Reverse().ToArray();
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900