C
C#12mo ago
Raf Camora

✅ How do i get a one digit hour and not to digit for example i want the hours are 2 and not 02

28 Replies
Raf Camora
Raf CamoraOP12mo ago
in the output i get the hours 02 and not 2 if i type 10000 seconds
SG97
SG9712mo ago
oddly my WithSecure does not like that URL
Raf Camora
Raf CamoraOP12mo ago
well then i have to type the code here
SG97
SG9712mo ago
$paste
MODiX
MODiX12mo ago
If your code is too long, you can post to https://paste.mod.gg/ and copy the link into chat for others to see your shared code!
Raf Camora
Raf CamoraOP12mo ago
BlazeBin - ofspwjjmgxwr
A tool for sharing your source code with the world!
Raf Camora
Raf CamoraOP12mo ago
here is it does it work
SG97
SG9712mo ago
yup
Raf Camora
Raf CamoraOP12mo ago
okay
SG97
SG9712mo ago
you can get the values like ts.Hours / ts.Minutes / ts.Seconds as in Console.WriteLine($"{ts.Seconds}");
Raf Camora
Raf CamoraOP12mo ago
but can i also do this? Console.WriteLine($"Seconds: {ts.Seconds}");
Angius
Angius12mo ago
Not like this, no Yes Like this
Raf Camora
Raf CamoraOP12mo ago
yeah hahah but
SG97
SG9712mo ago
you can without the interpolation but it just looks bad Console.WriteLine("Hours: {0} ", ts.Hours);
Raf Camora
Raf CamoraOP12mo ago
ts.Hours / ts.Minutes / ts.Seconds; this line gives an error
SG97
SG9712mo ago
sure it does, as it's not code I'm just mentioning the properties
Angius
Angius12mo ago
It was just listing the values, not actual code lol
Raf Camora
Raf CamoraOP12mo ago
oh
MODiX
MODiX12mo ago
Angius
REPL Result: Success
var ts = TimeSpan.FromSeconds(10_000);
$"{ts.Hours} hours, {ts.Minutes} minutes, {ts.Seconds} seconds"
var ts = TimeSpan.FromSeconds(10_000);
$"{ts.Hours} hours, {ts.Minutes} minutes, {ts.Seconds} seconds"
Result: string
2 hours, 46 minutes, 40 seconds
2 hours, 46 minutes, 40 seconds
Compile: 364.148ms | Execution: 30.108ms | React with ❌ to remove this embed.
Raf Camora
Raf CamoraOP12mo ago
the seconds must be an input the user needs to write
Angius
Angius12mo ago
Then make it an input ¯\_(ツ)_/¯
SG97
SG9712mo ago
just replace it
Raf Camora
Raf CamoraOP12mo ago
okay
Angius
Angius12mo ago
I'm just showing the interpolation
SG97
SG9712mo ago
you already have tha portion of the code correct (not error free but still) take input, create the TimeSpan, use the properties like ZZZZZZZZZZZZZZZZZZZZZZZZZ showed
Raf Camora
Raf CamoraOP12mo ago
alright thanks bye !close
SG97
SG9712mo ago
take care
Accord
Accord12mo ago
Closed!

Did you find this page helpful?