C# 编程设定为更改时变量C未更改?
当我将“c”编程为改变时,为什么它不会改变,这让我非常困惑。没什么好说的了,可能是个愚蠢的错误,但我想不出来C# 编程设定为更改时变量C未更改?,c#,C#,当我将“c”编程为改变时,为什么它不会改变,这让我非常困惑。没什么好说的了,可能是个愚蠢的错误,但我想不出来 //declared OUTSIDE of the method. private string c = "1"; private void expanded(object sender, GestureEventArgs e) { if (debug2.Text == "Temp") { if (c == "1") {
//declared OUTSIDE of the method.
private string c = "1";
private void expanded(object sender, GestureEventArgs e)
{
if (debug2.Text == "Temp")
{
if (c == "1")
{
c = "2";
((Storyboard)this.Resources["_in"]).Begin();
}
if (c == "2")
{
c = "1";
((Storyboard)this.Resources["_in1"]).Begin();
}
}
}
您缺少一个
或:
if (c == "1")
{
c = "2";
((Storyboard)this.Resources["_in"]).Begin();
}
else if (c == "2") // !!!
{
c = "1";
((Storyboard)this.Resources["_in1"]).Begin();
}
否则,您将c
设置为“2”
,然后立即返回到“1”
您将缺少一个或:
if (c == "1")
{
c = "2";
((Storyboard)this.Resources["_in"]).Begin();
}
else if (c == "2") // !!!
{
c = "1";
((Storyboard)this.Resources["_in1"]).Begin();
}
否则,您会将c
设置为“2”
,然后立即返回到“1”
这就是您想要做的吗
private: // <-- remember the colons (:)
string c = "1";
void expanded()
{
if(c = "1")
{
c = "2";
((Storyboard)this.Resources["_in"]).Begin(); //dono what this is
}
if(c == "2")
{
c = "1";
((Storyboard)this.Resources["_in1"])Begin(); //dono what this is
}
}
private://这就是你想要做的吗
private: // <-- remember the colons (:)
string c = "1";
void expanded()
{
if(c = "1")
{
c = "2";
((Storyboard)this.Resources["_in"]).Begin(); //dono what this is
}
if(c == "2")
{
c = "1";
((Storyboard)this.Resources["_in1"])Begin(); //dono what this is
}
}
private://调用方法时,debug2.Text
和c
的值是什么?c=1和debug2.Text=temp。是debug2。Text等于“temp”或“temp”“戴夫,这是一个打字错误。什么时候有值?”代码> Debug?文本< <代码> >代码> C >代码>当方法被调用时,C=1和Debug 2.文本= TEMP2。文本等于“TEMP”或“TEMP”?@戴夫是一个输入错误。OP是关于C++的,而不是C++ OP是关于C,而不是C++。