"macneed" <ma*****@yahoo.com.hkwrote in message
news:48********@127.0.0.1...
how can i declare a variable inside a if case?
if(today != recordday)
{
string[] NewRecordOfToday;
}
This IS correct. You can declare a variable in this way. But it is only
useful if you do some other work inside the { } block. The variable
disappears as soon as you reach the closing bracket.
[...]
if(today != recordday)
{
NewRecordOfToday[0] = "Fine";
}
This is NOT correct. The scope of a variable is limited to the block
that encloses it. If you want a variable to be accessible from both blocks,
you have to declare it OUTSIDE both blocks.
and the variable can USE outside of if { }
if the if case not pass, the variable doesn't need...
I'm not able to understand the preceding sentences. Perhaps you could
enlist someone else's help in revising your English.