Answer the question
In order to leave comments, you need to log in
How to determine time difference in milliseconds between two animation slides in C# environment?
The animation is set per slide by counter K. It is necessary to determine the time in milliseconds between 7 and 9 slides.
Here is the part of the code
if (k == 7)
{
pictureBox1.Image = Resources._7;
var x = DateTime.Now.ToString("ss:fff" );
}
if (k == 8)
{
pictureBox1.Image = Resources._8;
}
if (k == 9)
{
pictureBox1.Image = Resources._7;
var y = DateTime.Now.ToString("ss:fff" );
TimeSpan diff1 = x - y;
Gives an error "The name x does not exist in this context"
When I try to fix this error, it says that the operation "-" cannot be performed with variables of type string.
Help me please
Answer the question
In order to leave comments, you need to log in
Gives the error "The name x does not exist in this context"right
if (k == 7)
{
pictureBox1.Image = Resources._7;
var x = DateTime.Now.ToString("ss:fff" );
}
// после этой фигурной скобки x уже не существует
var x = "";
if (k == 7)
{
pictureBox1.Image = Resources._7;
x = DateTime.Now.ToString("ss:fff" );
}
+
but this is gluing lines. there is no dynamic type conversion in C# (although there is a default type casting , but not always) Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question