我正试图解决这个问题:
我有很多分钟,我想把它们转换成几小时,当我尝试时TimeSpan,它总是显示几天和几小时.
我的示例代码:
double minutes = 2000 ;
TimeSpan hours = TimeSpan.FromMinutes(minutes);
label1.Text = hours.ToString(@"hh\:mm");
Run Code Online (Sandbox Code Playgroud)
输出结果是 09:20, 但我希望这个结果33:20
如何转换分钟以获得确切的小时数?
我有一个带doc文件的目录(名字名字)
例如我有这个:
Doe John.doc
Doe Phil.doc
Doe Robert.doc
Poe Dameron.doc
我有一个包含数据库中所有人的列表框,我选择一个名称,然后单击"打开文件"
我的代码:
string fullname = Name + " " + Firstname;
string[] allFiles = Directory.GetFiles((Doc_Path));
foreach (string file in allFiles)
{
if (file.Contains(fullname))
{
Process.Start(file);
return;
}
// if it cant found fullname, try to open by Name only
else if(file.Contains(Name))
{
Process.Start(file);
return;
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题 :
如果我选择Doe Robert,它会在所有情况下打开Doe John,但它应该在第一个IF指令处停止
即使它是基础知识我也不明白:/