c# 问题:不包含采用0个参数的构造函数。。。
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespa...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace exe_3
{
class Program
{
static void Main(string[] args)
{
DiscrFruit fruit=new DiscrFruit();
fruit.Name = Console.ReadLine();
String a = "orange";
String b = "apple";
if (fruit.Name.Equals(a))
{
fruit.DiscrOrange();
}
else if (fruit.Name.Equals(b))
fruit.DirscrApple();
else
Console.ReadLine();
Console.ReadLine();
}
}
class Fruit {
public String Name;
public Fruit(String name)
{
Name = name;
}
}
class DiscrFruit:Fruit
{
public void DirscrApple()
{
Console.WriteLine("This is an apple!");
}
public void DiscrOrange()
{
Console.WriteLine("This is an orange!");
}
}
}
提示"exe_3.Fruit"不包含采用“0”个参数的构造函数。。。
刚学C#,不知道怎么解决这个问题,求大神解答 展开
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace exe_3
{
class Program
{
static void Main(string[] args)
{
DiscrFruit fruit=new DiscrFruit();
fruit.Name = Console.ReadLine();
String a = "orange";
String b = "apple";
if (fruit.Name.Equals(a))
{
fruit.DiscrOrange();
}
else if (fruit.Name.Equals(b))
fruit.DirscrApple();
else
Console.ReadLine();
Console.ReadLine();
}
}
class Fruit {
public String Name;
public Fruit(String name)
{
Name = name;
}
}
class DiscrFruit:Fruit
{
public void DirscrApple()
{
Console.WriteLine("This is an apple!");
}
public void DiscrOrange()
{
Console.WriteLine("This is an orange!");
}
}
}
提示"exe_3.Fruit"不包含采用“0”个参数的构造函数。。。
刚学C#,不知道怎么解决这个问题,求大神解答 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询