结构函数的一个例子

struct order
        {
            public string itemName;
            public int unitCount;
            public double unitCost;
            public double SumCost()  
            {
                return unitCount * unitCost;
            }
            public string OrderInformation()
            {
                return "Order information: " + unitCount + " " + itemName + " " + "item at $" + unitCost + " each, total cost $" + SumCost();
            }
        }
 
        static void Main(string[] args)
        {
            order bill;
            bill.itemName = "Milk";
            bill.unitCount = 10;
            bill.unitCost = 0.3;
            Console.WriteLine(bill.SumCost());
            Console.WriteLine(bill.OrderInformation());
            Console.ReadKey();
        }

第6章练习题5

暧昧帖

Tags :

Google Reader Yahoo Facebook Twitter Digg FriendFeed Delicious Google Translate
This entry was posted onJuly 9th, 2009 at 14:41. You can follow any responses to this entry through the RSS 2.0. You can Leave a response, or Trackback.

Leave a Reply

(Ctrl+Enter)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

25 queries. 0.187 seconds