您的位置:首页 > 其它

6_8_5在order结构体中添加一个函数.该结构体返回一个格式化的字符串,以合适的值替换用尖括号扩起来的条目

2012-10-02 01:57 295 查看
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _6_8_5
{
class Program
{
struct order
{
public string itemName;
public int unitCount;
public double unitCost;

public double end()
{
double max = unitCount * unitCost;
return max;
}

public void Display()
{
string str = unitCount + " " + itemName + " item at " + unitCost + " " + " each , total cost " + end();
Console.WriteLine(str);
}
}

static void Main(string[] args)
{
order book;
book.itemName = "C++ Primer 4th";
book.unitCount = 100;
book.unitCost = 75;
book.end();
book.Display();

//Console.WriteLine("书的总金:{0}", book.end());
}
}
}


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐