New Class

1): New a class, which can be used in the form1.
Write following code in form1.
   private AxisLimits al;  // This command will define a private variable al, this al
                                  //  variable has the characteristic of Class AxisLimits.
        private form1()
       {
          initialization...
          a1 = new AxisLimits();
       }
        private void AxisLimitSettings()
        {
         Applicationdata.ListXMax.Add(al.XMax);
         }
        private ...
          {
           }
-------------------------
al can be used in form1, and all method in form1.
===========================================
2): New a class, which can be used in a single method

   private form1()
        {
          initialization...
         }
        private void AxisLimitSettings()
        {
         AxisLimits a1 = new AxisLimits();
         Applicationdata.ListXMax.Add(al.XMax);
         }
        private ...
          {
           }

    a1 can be used in AxisLimitSettings.




原文地址:https://www.cnblogs.com/greencolor/p/1565060.html