prosseek
prosseek

Reputation: 190959

error CS1501: No overload for method `Reverse' takes `0' arguments

I have this code to reveres the words in a sentence.

using System;

class Code 
{
    public static void Main()
    {
        string x = "I am Sam";

        foreach(var a in x.Split().Reverse()) 
        {
            Console.WriteLine(a);
        }
    }
}

When I compile this code (mono 2.10), I got error CS1501: No overload for methodReverse' takes 0' arguments error message.

What's wrong with the code?

Upvotes: 1

Views: 4447

Answers (1)

Ahmad Mageed
Ahmad Mageed

Reputation: 96507

Add the System.Linq namespace:

using System.Linq;

Upvotes: 10

Related Questions