当前上下文中不存在名称“If” [英] The name 'If' does not exist in the current context

查看:149
本文介绍了当前上下文中不存在名称“If”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

其实我在C#2010中全新了

所以我在IF声明中遇到了简单问题



所以我的代码是

Actually i am totallynew in C# 2010
so i have simple problem in IF Statement

So my code is

private void Timer1_Tick(object sender, EventArgs e)
{
   ProgressBar1.Value += 1;

   if (ProgressBar1.Value<=10)
   {
      Label1.Text = "Loading Application . . .";
   }    
   else if (ProgressBar1.Value <= 20)
   {
   }
   else if (ProgressBar1.Value <= 40)
   {
   }
   else if (ProgressBar1.Value <= 60)
   {
   }
   else if (ProgressBar1.Value <= 80)
   {
   }
  else if (ProgressBar1.Value <= 100)
  {
    Label1.Text = "Starting Application . . .";
  }
    If(ProgressBar1.Value == 100)
  {
     Timer1.Dispose();
            
    }
 }



名称''如果''不存在在当前上下文错误我得到



/编辑由Jibesh添加的预标记

推荐答案

错误意味着关键字如果错误你应该使用小如果你在上面定义。



如果你使用visual studio''if''关键字会在正常情况下变成蓝色。在上面的例子中,你使用的是大写字母if不是关键字。
The error means the Keyword If is wrong you should use small if as you define above.

if you are using visual studio ''if'' keyword will turn blue color normally. in the above case you used a capital If which is not a keyword.


欢迎来到C#编程世界。既然你是新手,你应该集中精力理解C#编程中的基础知识和语法,而不是直接跳转到编程。



今天的课程是 - C#是一种区分大小写的语言。所以''如果' '不等于''如果''


''if''语句的C#语法是

Welcome to the world of C# programming. Since you are new, you should concentrate on understanding the basics and syntaxes in C# programming instead of directly jumping to programming.

Your lesson for today is - C# is a case-sensitive language. So a ''If'' is not equal to ''if''

C# syntax for ''if'' statement is
if(<<condition that evaluates to bool>>)
{
//Your code here
}


纠正if的拼写。它的如果并且你正在写如果看到你输入的首都我而不是i在最后如果



Correct spellings of "if". its "if" and you are writing "If" see the capital "I" you placed instead of "i" in the last if

If(ProgressBar1.Value == 100)
 {
    Timer1.Dispose();

   }





应该是





should be

if(ProgressBar1.Value == 100)
 {
    Timer1.Dispose();

   }


这篇关于当前上下文中不存在名称“If”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆