这道题错在哪里了,不难using System;using System.Collections.Generic;using System.Text;namespace _{class Program{static void Main(){class1 c1 = new class1();c1.str2 = "shanghai";class2 c = new class2();c.sum();}}class class1{protected string
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/19 21:02:52
这道题错在哪里了,不难using System;using System.Collections.Generic;using System.Text;namespace _{class Program{static void Main(){class1 c1 = new class1();c1.str2 = "shanghai";class2 c = new class2();c.sum();}}class class1{protected string
这道题错在哪里了,不难
using System;
using System.Collections.Generic;
using System.Text;
namespace _
{
class Program
{
static void Main()
{
class1 c1 = new class1();
c1.str2 = "shanghai";
class2 c = new class2();
c.sum();
}
}
class class1
{
protected string str1;
public string str2
{
get
{
return str1;
}
set
{
str1 = str2;
}
}
}
class class2:class1
{
public void sum()
{
string str3 = base.str1;
Console.WriteLine("{0}",str3);
}
}
}
这道题错在哪里了,不难using System;using System.Collections.Generic;using System.Text;namespace _{class Program{static void Main(){class1 c1 = new class1();c1.str2 = "shanghai";class2 c = new class2();c.sum();}}class class1{protected string
using System;
using System.Collections.Generic;
using System.Text;
class Program
{
static void Main()
{
class2 c = new class2();
c.str2 = "shanghai";
c.sum();
}
}
class class1
{
protected string str1;
public string str2
{
get
{
return str1;
}
set
{
str1 = value;
}
}
}
class class2 : class1
{
public void sum()
{
string str3 = base.str1;
Console.WriteLine("{0}", str3);
}
}
这样改就行了,另外你对派生和继承理解得不清楚,自己摸索吧……