您的位置:首页 > 编程语言 > C#

C#构造函数中的this()

2008-12-16 21:36 169 查看
using System;

public class Test

{

public int int_x;

public string str_x;

public byte byte_x;

public Test()

{

this.int_x=10;

this.str_x="I love you more than I can say !";

this.byte_x=5;

}

public Test(string str):this()

{

this.str_x=str;

}

static void Main()

{

Test te=new Test("You are my sunshine..");

Console.WriteLine("te.int_x={0}\n",te.int_x);

Console.WriteLine("te.str_x={0}\n",te.str_x);

Console.WriteLine("te.byte_x={0}\n",te.byte_x);

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: