2014-11-25 72 views
0

我在Visual Studio 2010中對此進行了編碼,並且我有Windows 8 ...但是錯誤是要適當地設置輸出路徑和程序集名稱屬性以指向目標程序集的正確位置...我如何將這些設置爲刪除錯誤並運行此代碼?如何在Visual Studio 2010中設置輸出路徑和程序集名稱?

代碼是:

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

namespace RectangleApplication 
{ 
    class Rectangle 
    { 
     public double width; 
     public double length; 

    } 

    public double GetArea() 
      { 
    return width*length; 
} 

    public void Display() 
{ 
    Console.WriteLine("Lenght:{0}", length); 
    Console.WriteLine("Width: {0}" , width); 
    Console.WriteLine("Area: {0}" , GetArea()); 
} 

    class ExecuteRectangle 
    { 
     static void Main(string[] args) 
     { 
      Rectangle r = new Rectangle(); 
      r.length = 3.5; 
       r.width =4.5; 
      r.Display(); 
      Console.ReadLine(); 

     } 
    } 
} 
+1

請顯示_exact_錯誤消息,在哪一刻出現以及您嘗試解決它的內容。請參閱例如[調試目標缺少?](http://stackoverflow.com/questions/3516333/debug-target-is-missing)。 – CodeCaster 2014-11-25 11:45:53

+1

如果你想正確地設置你的代碼的格式,你會發現'GetArea()'和'Display()'在它們自己的外部浮動,而不是任何類,這是不允許的。如果它不是你當前錯誤的原因,那麼在修復那個錯誤之後它肯定會成爲你的下一個問題。編譯此代碼後 – 2014-11-25 11:48:45

+0

錯誤消息是 「請爲目標裝配正確的位置適當設置outpath中和組裝名稱屬性點」 我試圖上傳的圖像它......但現在不能在這裏加載 – 2014-11-25 12:09:19

回答

0

將其更改爲以下:

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

    namespace RectangleApplication 
    { 
     public class Rectangle 
     { 
      public double width; 
      public double length; 

      public double GetArea() 
      { 
       return width * length; 
      } 

      public void Display() 
      { 
       Console.WriteLine("Lenght:{0}", length); 
       Console.WriteLine("Width: {0}", width); 
       Console.WriteLine("Area: {0}", GetArea()); 
      } 
     } 

     public class ExecuteRectangle 
     { 
      public static void Main(string[] args) 
      { 
       Rectangle r = new Rectangle(); 
       r.length = 3.5; 
       r.width = 4.5; 
       r.Display(); 
       Console.ReadLine(); 

      } 
     } 
    } 

的問題是,你已經把Rectangle類外GETAREA和顯示功能。

+0

代碼很好,但編譯後出現此錯誤「請將OutPath和程序集名稱屬性適當地設置爲指向目標程序集的正確位置」 – 2014-11-25 12:29:41

+0

嘗試並創建一個新項目,將「Program.cs」的內容替換爲「進入上面的代碼並嘗試再次構建它。 它可能是一些一般設置已被損壞。 – 2014-11-25 12:37:51

+0

謝謝....它現在的作品:) – 2014-11-25 12:47:29

相關問題