分類  >  WEB開發>C# >

為什麼編好運行控制台應用程序時,出現異常,說是無法創建新的堆棧防護頁面

tags:    時間:2013-12-18 18:05:01
為什麼編好運行控制台應用程序時,出現錯誤,說是無法創建新的堆棧防護頁面
[code=C#][/code]using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication6
{
  public abstract class Animal
  {
  public int x;
  public int y;
  public int X
  {
  get
  {
  return x;
  }
  set
  {
  X = ((value >= 1) && (value <= 168)) ? value : 0;
  }
  }
  public int Y
  {
  get
  {
  return y;
  }
  set
  {
  Y = ((value >= 1) && (value <= 168)) ? value : 0;
  }
  }
  public Animal(int m, int n)
  {
  X = m;
  Y = n;
  }
  public abstract void Move();

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

namespace ConsoleApplication6
{
  class Fish:Animal 
  {
  public Fish(int m, int n)
  :base (m,n)
  {
  X += 10;
  Y += 10;
  }
  public override void Move()
  {
  Console.WriteLine("Fish:\nX={0}\nY={1}",X,Y);
  }
  }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication6
{
  class Frog:Animal 
  {
  public Frog(int m, int n)
  :base (m,n)
  {
  X += 20;
  Y += 20;
  }
  public override void Move()
  {
  Console.WriteLine("Frog:\nX={0}\nY={1}",X,Y);
  }
  }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication6
{
  class Bird:Animal 
  {
  public Bird(int m, int n)
  :base (m,n)
  {
  X += 30;
  Y += 30;
  }
  public override void Move()
  {
  Console.WriteLine("Fish:\nX={0}\nY={1}",X,Y);
  }
  }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication6
{
  class Program
  {
  static void Main(string[] args)
  {
  Fish f = new Fish(14, 16);
  Frog g = new Frog(45, 36);
  Bird b = new Bird(22, 56);
  Animal[] a = new Animal[2];
  a[0] = f;
  a[1] = g;
  a[2] = b;
  a[0].Move();
  a[1].Move();
  a[2].Move();
   
  }
  }
}


------解決方案--------------------
public int X
{
get
{
return x;
}
set
{
x = ((value >= 1) && (value <= 168)) ? value : 0;
}
}
public int Y

推薦閱讀文章

Bookmark the permalink ,來源:互聯網