How can I use the same name for two or more different variables in a single C# function? -
How can I use the same name for two or more different variables in a single C# function? -
how delete variable 1 time declared , defined?
for example, in c++ do:
int x; .. delete x;
how can in c#?
(i need this:
switch (something) { case 1: int number; break; case 2: float number; break; }
but can't it, because number taken case 1... , want same name, want delete int number before float number declared, compilator won't shout @ me. ;p
you can create scopes non-overlapping using braces:
switch (something) { case 1: { int number; } break; case 2: { float number; } break; }
going out of scope way variable name "deleted" in sense talking about. notably , unlike other languages, c# doesn't allow hiding local variables other variables in more limited scopes -- scopes have non-overlapping (and in c#, means opening brace, not point of declaration!). mean code, legal in c , c++ (not sure java) cause compiler error in c#:
int number; { float number; }
c# variables scope identifier
Comments
Post a Comment