c# - 在控制台应用程序中打印从我的代码返回的值
问题描述
我正在尝试在我的控制台应用程序中显示计算结果。所以它将发送这个类
namespace The_Code_Challenge
{
class HeatCalculator
{
public static decimal ActualHeatRate(decimal TotalHeatInput, decimal ActualNetGeneration, GeneratorType generatorType)
{
return TotalHeatInput / ActualNetGeneration;
}
}
}
到我的主要
namespace The_Code_Challenge
{
class MyClassCS
{
static void Main()
{
FileWatch.Initialize();
}
}
}
我的问题是:我如何在我的main
? 以及如何显示我的结果?
解决方案
你需要使用Console.WriteLine()
.
您的课程HeatCalculator
必须是公开的。
HeatCalculator calc = new HeatCalculator(); Console.WriteLine(calc.ActualHeatRate(1,2,generatorType));
希望它能回答你的问题。
推荐阅读
- java - 如何在退出时保存进度和 GUI 状态?
- javascript - 运行多个 React 应用程序并使用一个文件夹中的常用组件
- tsc - 防止 TSC 排放出口
- android - 在 Android 房间数据库中查询全文搜索表
- ruby-on-rails - 如何在 Rails before_save 回调中验证两个 Geocoder 对象的 distance_to 小于 200 mts?
- python - 删除双行或多行空并保留单行空
- java - 将 PDF 转换为 Word,包括链接
- nginx - Nginx 和 Kong Api 网关之间的 mTLS
- javascript - 注册表格类似于 facebook 一次 CSS
- qt - 使用 Qt EGLFS 时使用 QLabel 取消引用空指针