5

I have a problem. I have been following a tutorial, so that I could learn programming with Xamarin. Well now I have this error line, that I have written in the title. Here's the code for you all;

using System.Collections.ObjectModel;
using UIKit;

namespace freesongsforme
{
    static void Main(string[] args)
    { 
        var listView = new ListView();
        var myTrainers = new ObservableCollection<string>() 
        { 
            "Song 1",
            "Song 2",       
        };

        listView.ItemsSource = mySongs; 

        myTrainers.Add("Songsr");
    }

The ''main'' part is marked as an error.

Rufus L
  • 36,127
  • 5
  • 30
  • 43
evanthomas570
  • 51
  • 1
  • 1
  • 2
  • 1
    `Class` is missing from your code. – Akash Amin Jun 02 '16 at 12:59
  • C# is object-oriented language. At least *one* object must be created as an absolute minimum for C# console app to run (and it should contain entry point which is `static void Main()`) – Fabjan Jun 02 '16 at 13:47

1 Answers1

13

your code needs to be contained within a Class

namespace freesongsforme
{

  public class MyClass {

    static void Main(string[] args)
    { 
      var listView = new ListView();
      var myTrainers = new ObservableCollection<string>() { 

        "Song 1",
        "Song 2",

      };

    listView.ItemsSource = mySongs; 

    myTrainers.Add("Songsr");

  }
}
Community
  • 1
  • 1
Jason
  • 86,222
  • 15
  • 131
  • 146