2015-04-22 73 views
-1

首先要說我已經閱讀了類似的問題,並且我嘗試了所有的東西。在這個階段全面虧損。該錯誤消息如下:控制檯應用程序持久性錯誤不包含適用於入口點的靜態主要方法

錯誤1個計劃 'C:\用戶\ EPM \桌面\ C#的工作\項目\ ConsoleApplication10 \ ConsoleApplication10 \ OBJ \ 86 \調試\ ConsoleApplication10.exe' 不包含靜態適合的切入點

「主」方法然後又通知彈出後,我嘗試,儘管它說生成錯誤運行它

的Visual Studio無法啓動調試,因爲調試目標「C :\用戶\ EPM \桌面\ C#的工作\項目\ ConsoleApplication10 \ ConsoleApplica tion10 \ bin \ Debug \ ConsoleApplication10.exe'丟失。請構建項目並重試,或者適當地設置OutputPath和AssemblyName屬性以指向目標程序集的正確位置。

我已經花了很多時間嘗試我可以在互聯網上找到的每個解決方案,如果有人能幫助我,我會很感激。謝謝。

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

namespace ConsoleApplication10 
{ 
    class Program 
    { 

     static void main() 
     { 
      List<Student> list = new List<Student>(); 
      list.Add(new Student() { Name = "Alan", Grade = 100 }); 
      list.Add(new Student() { Name = "Jane", Grade = 100 }); 
      list.Add(new Student() { Name = "Aidan", Grade = 90 }); 
      list.Add(new Student() { Name = "Bill", Grade = 50 }); 
      list.Add(new Student() { Name = "Liam", Grade = 80 }); 

      list.Sort(); 

      foreach (var element in list) 
      { 
       Console.WriteLine(element); 
      } 
     } 

     class Student : IComparable<Student> 
     { 
      public int Grade { get; set; } 
      public string Name { get; set; } 

      public int CompareTo(Student other) 
      { 
       if (this.Grade == other.Grade) 
       { 
        return this.Name.CompareTo(other.Name); 
       } 

       else return other.Grade.CompareTo(this.Grade); 
      } 

      public override string ToString() 
      { 
       return this.Grade.ToString() + "," + this.Name; 
      } 
     } 
    } 
} 
+4

'static void Main()' - Capital M –

+0

區分大小寫主要不少主... – kmcnamee

+0

我的話,我是一個適當的eejit。非常感謝。我真的很感謝你看看。 – EpicurealDogMan

回答

2

C#程序的主要方法通常如下所示:

public static void Main(string[] args) 
{ 
    // Your code 
} 
0

當建立在C#中的一個項目,主要的方法是這樣寫的:

static void Main(){...} 

請注意「Main」中的首字母「M」。

在Java中,主要方法是用小寫「m」編寫的,如果這是您的想法。

0

如果有疑問,只需使用「新項目 - > c#控制檯應用程序」嚮導創建一個新的控制檯應用程序,就可以看到。

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

namespace ConsoleApplication1 
{ 
    class Program 
    { 
     static void Main(string[] args) 
     { 
     } 
    } 
} 

大寫字母M和字符串[] args是嚮導生成的內容。

相關問題