两个类的效果

来源:百度知道 编辑:UC知道 时间:2024/09/25 16:36:59
public class person
{
string firstname,lastname;
int age;
public void theperson(string first, string last, int theage)
{
this.firstname = first;
this.lastname = last;
if (theage < 18)
throw new Exception ("ERROR:Person is not a adult:)");
this.age = theage;
}

}
public class TestForType2
{
public void Main(string firstName, string lastName, int age)
{
string a = firstName,b = lastName;
int c = age;
try
{
person p = new person();
p.theperson(a, b, c);

}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
}

这个是我的后台文件
public partial class _Defa

Console.WriteLine()是在控制台输出用的。

页面输出用:

Response.Write("your string");

B/S和C/S要分清

Console.WriteLine是在控制台程序中向控制台输出一行,在控制台程序中可见

还有你确实问错板块了

baidu问不到的话··可以去csdn上问问··

老大 你选错问题的类别了 - - 这里是图像处理软件区