class1.cs

来自「C#开发教程 由浅入深 配有实例 是初学者的好帮手」· CS 代码 · 共 43 行

CS
43
字号
using System;

namespace DefaultCtors
{
	class File
	{
	}

	class CommaDelimitedFile
	{
		// these two lines are the same
//		public CommaDelimitedFile(String fileName) : this()
		public CommaDelimitedFile(String fileName)
		{
			Console.WriteLine("Constructed with a file name");
		}

		public CommaDelimitedFile(File file)
		{
			Console.WriteLine("Constructed with a file object");
		}
		public CommaDelimitedFile() : this("Default string")
		{
		}
	}

	class Class1
	{
		[STAThread]
		static void Main(string[] args)
		{
			File file = new File();
			CommaDelimitedFile file2 = 
				new CommaDelimitedFile(file);
			CommaDelimitedFile file3 = 
				new CommaDelimitedFile("Some file name");

			CommaDelimitedFile file4 = 
				new CommaDelimitedFile();
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?