Model/TemperatureEntity.cs
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.ComponentModel;
namespace UnitTransform.Model
{
/// <summary>
/// 摄氏温度和华氏温度间不是比率关系,所以不能直接继承自AbstractEntity
/// </summary>
public class TemperatureEntity : INotifyPropertyChanged, IClearInput
{
private string cELSIUS;
//摄氏温度
public string CELSIUS
{
get { return cELSIUS; }
set
{
double c = 0;
if (double.TryParse(value, out c))
{
cELSIUS = value;
kELVIN = (c + 273.15).ToString();
string v = (9.0 / 5 * c + 32).ToString();
fahrenheit = v;
PropertyChange("CELSIUS");
PropertyChange("KELVIN");
PropertyChange("Fahrenheit");
}
}
}
private string fahrenheit;
//华氏温度
public string Fahrenheit
{
get { return fahrenheit; }
set
{
double f = 0;
if (double.TryParse(value, out f))
{
fahrenheit = value;
double temp = 5.0 / 9 * (f - 32);
string c = temp.ToString();
string k = (temp + 273.15).ToString();
cELSIUS = c;
kELVIN = k;
PropertyChange("Fahrenheit");
PropertyChange("CELSIUS");
PropertyChange("KELVIN");
}
}
}
private string kELVIN;
//开尔文
后面还有 40 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。