C # variable instance, credit card case

. 1  the using the System;
 2  the using the System.Collections.Generic;
 . 3  the using the System.Linq;
 . 4  the using the System.Text;
 . 5  the using System.Threading.Tasks;
 . 6  
. 7  namespace Demo2
 . 8  {
 . 9      class Program
 10      {
 . 11          static  void the Main ( String [ ] args)
 12 is          {
 13 is              as Consume Consume = new new as Consume (); // Since class does not use static, first create an object class 
14             consume.Record ();
 15          }
 16      }
 . 17      class Card // define a class card 
18 is      {
 . 19          public  string Money { GET ; SET ;} // defines the string type is defined as a keyword Money 
20 is      }
 21 is      class as Consume // definition of a Purchase History class display 
22 is      {
 23 is          public  void the record () // defines a method for recording consumption 
24          {
 25              Console.WriteLine ( " Credit Card Purchase History \ n- " );
26              Card pCard = new new Card () {Money = " 8000 " }; // create the object principal credit card, to assign Money 
27              Console.WriteLine ( " credit card total of: " + pCard.Money); // output initial amount, Money attribute value of the main card 
28              card SCARD = pCard; // create an object Vice card 
29              sCard.Money = " 3000 " ; // indication Vice card spending the 3000 
30              Console.WriteLine ( " credit card record: " + pCard. Money); // Check credit card spending records, carried out with the main card Check 
31             Console.Read();
32         }
33     }
34 }

 

Guess you like

Origin www.cnblogs.com/ZHANG576433951/p/11130890.html