Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undeclare Variables in C#

Tags:

c#

Is it possible to undeclare variables in C#? If so, how?

like image 210
GibboK Avatar asked Jul 29 '10 07:07

GibboK


People also ask

How do you declare a variable in C?

Declaring (Creating) Variablestype variableName = value; Where type is one of C types (such as int ), and variableName is the name of the variable (such as x or myName). The equal sign is used to assign a value to the variable.

How do you declare variables?

To declare (create) a variable, you will specify the type, leave at least one space, then the name for the variable and end the line with a semicolon ( ; ). Java uses the keyword int for integer, double for a floating point number (a double precision number), and boolean for a Boolean value (true or false).

How can you declare the variable in C with example?

a) General syntax for declaring a variable Eg:- char Final_Grade; // Final_Grade is a variable of type char, and no value is assigned to it. data_type variable_name = val; Eg:- int age = 22; // age is a variable of type int and holds the value 22. Here, data_type specifies the type of variable like int, char, etc.

What is variables in C?

A variable is a name of the memory location. It is used to store data. Its value can be changed, and it can be reused many times. It is a way to represent memory location through symbol so that it can be easily identified.


1 Answers

close the scope (introduced with '{') that contains the variable declaration:

int c=0;
{
 int a=1;
 {
  int b=2; 
  c=a+b;
 } // this "undeclares" b
 c=c+a;
} // this "undeclares" a
like image 129
Nordic Mainframe Avatar answered Nov 15 '22 01:11

Nordic Mainframe