1条回答 默认 最新
- CSDN专家-showbo 2021-10-03 15:31关注
题主要的代码如下,有帮助麻烦点个采纳【本回答右上角】,谢谢~~有其他问题可以继续交流~
using System; namespace ConsoleApp1 { class Box { public double Length { get; set; } public double Width { get; set; } public double Height { get; set; } public void SetBox(double Length,double Width, double Height) { this.Length = Length; this.Width = Width; this.Height = Height; } public double GetVolume() { return Length * Width * Height; } public double GetArea() { return (Length * Width + Length * Height + Width * Height) * 2; } } class Program { static void Main(string[] args) { var box = new Box { Length = 3, Width = 4, Height = 5 }; Console.WriteLine("体积:" + box.GetVolume()); Console.WriteLine("面积:" + box.GetArea()); box.SetBox(5, 5, 5); Console.WriteLine("体积:" + box.GetVolume()); Console.WriteLine("面积:" + box.GetArea()); Console.ReadKey(); } } }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 2无用
悬赏问题
- ¥20 西门子S7-Graph,S7-300,梯形图
- ¥50 用易语言http 访问不了网页
- ¥50 safari浏览器fetch提交数据后数据丢失问题
- ¥15 matlab不知道怎么改,求解答!!
- ¥15 永磁直线电机的电流环pi调不出来
- ¥15 用stata实现聚类的代码
- ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
- ¥20 docker里部署springboot项目,访问不到扬声器
- ¥15 netty整合springboot之后自动重连失效
- ¥15 悬赏!微信开发者工具报错,求帮改