2014-11-25 73 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

相关问题