ch6_1test.cs

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

CS
87
字号
using System;

public enum DayOfTheWeek
{
	Monday,
	Tuesday,
	Wednesday,
	Thursday,
	Friday,
	Saturday,
	Sunday
};

public struct _SYSTEM_INFO
{ 
   public int dwOemID; 
   public int dwPageSize;
   public int lpMinimumApplicationAddress; 
   public int lpMaximumApplicationAddress; 
   public int dwActiveProcessorMask; 
   public int dwNumberOfProcessors;
   public int dwProcessorType;
   public int dwAllocationGranularity;
   public short wProcessorLevel;
   public short wProcessorRevision;
}


public interface Channel
{
   void Next();
   void Previous();
}

public class TestIntf : Channel
{
   public void Next()
   {
      Console.WriteLine("Channel Next");
   }
   public void Previous()
   {
      Console.WriteLine("Previous");
   }
}

public class EventTestClass
{
     // The value to track
     private int nValue;
     
     // Allow a handler for the event
     public delegate Boolean ValueChangedEventHandler(int nValue);
     
     // This is the event itself
     public event ValueChangedEventHandler Changed;

     // This method is used to fire the event     
     protected virtual Boolean OnChanged(int nV) 
     {
        if (Changed != null)
           return Changed(nV);
        else
           Console.WriteLine("Event fired. No handler!");
	return true;
    
     }
     public EventTestClass(int nValue)
     {
        SetValue( nValue );
     }
     public void SetValue( int nV )
     {
        if ( nValue != nV )
        {
            if ( OnChanged(nV) )
               nValue = nV;
            // Fire the event
        }
     }
     public static void Main()
     {
     }
    
}

⌨️ 快捷键说明

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