ch7_01.cs

来自「《c#技术内幕代码》」· CS 代码 · 共 57 行

CS
57
字号
using System; // For the Console definition
using System.IO; // For TextWriter definition

class ATestClass
{
   private int x;
   private double y;
   private string s;
   
   public ATestClass()
   {
      x = 10;
      y = 23.45;
      s = "ATestClass Information";
   }
   public void Dump(TextWriter o)
   {
      o.WriteLine("X = {0}", x );
      o.WriteLine("Y = {0}", y );
      o.WriteLine("S = {0}", s );
   }
}


class CH7_1
{
   public static void Main()
   {
      // Output a few things to the console
      Console.WriteLine("This is a test");
      Console.WriteLine("This is an integer: {0}", 1 );
      
      ATestClass test = new ATestClass();
      Console.WriteLine("This is an object: {0}", test );
      Console.WriteLine("This is a dump of an object:");
      test.Dump( Console.Out );
      
      // Get input from the user until they say "End"
      Boolean done = false;
      while ( !done )
      {
         string s = Console.ReadLine();
	 if ( s == "End" )
	    break;
      }
      
      // Output things without a line break
      Console.Write("This");
      Console.Write(" ");
      Console.Write("is");
      Console.Write(" ");
      Console.Write("a");
      Console.Write(" ");
      Console.Write("test");
   }
}

⌨️ 快捷键说明

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