2.5.txt
来自「《Microsoft Visual C# .NET 2003开发技巧大全》源代码」· 文本 代码 · 共 30 行
TXT
30 行
Listing 2.5 Overloading a Constructor Is Similar to Overloading a Regular Class
Method
using System;
namespace _6_Constructors
{
public class Television
{
public Television() : this(2)
{
}
public Television( int initChannel )
{
channel = initChannel;
}
private int channel;
public int GetChannel()
{
return channel;
}
}
class Class1
{
[STAThread]
static void Main(string[] args)
{
Television tv = new Television(42);
Console.WriteLine( “TV Channel = {0}”, tv.GetChannel() );
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?