我在F2008
module mod_Blood
use mod_liquid
implicit none
type, public :: typ_BloodComponents
character(len=5) :: name
real(DP):: salt
real(DP):: RBC
end type typ_BloodComponents
type, public :: typ_BloodWork
real(DP) :: DrugConc
real(DP) :: Dilution
real(DP) :: volume
type(typ_BloodComponents) :: vein, artery
contains
procedure :: SetParameters => blood_SetParameters
procedure :: BloodProteinParams => blood_BloodProteinParams
end type typ_BloodWork
end mod_Blood
我知道静脉和动脉都有变量静脉%名称,静脉%盐,静脉%RBC和动脉%名称,动脉%盐和动脉%RBC。
如何将其转移到C#?模块是命名空间吗?并且是一个FORTRAN“类型”C#中的类?
如果我做了类似的事情,那会有意义吗?
class BloodComponents
{
string name;
double salt;
double RBC;
}
class BloodWork
{
double drugConc
double dil
double volume
class Vein : BloodComponents
{}
class Artery : BloodComponents
{}
void SetParameters()
{...}
void BloodComponentParameter()
{...}
}
或者我解释FORTRAN错了吗?
答案 0 :(得分:0)
我认为这就是你想要的:
namespace Blood
{
public struct BloodComponents
{
public string name;
public double salt, RBC;
}
public struct BloodWork
{
public double drugConc, dilution, volume;
public BloodComponents vein, artery;
public void SetParameters()
{
}
public void BloodProteintParams()
{
}
}
class Program
{
static void Main(string[] args)
{
var work=new BloodWork()
{
drugConc=0.1,
dilution=0.2,
volume=0.3,
vein=new BloodComponents() { name="A", RBC=0.2, salt=0.6 },
artery=new BloodComponents() { name="B", RBC=0.5, salt=0.9 }
};
}
}
}
所有内容都是struct
,因此仅复制值。如果您想在多个地方引用BloodWork
的同一时刻,则需要将类型更改为class
。