>Hi,
>Does C# support same name in sub method?
>For example, I have declare string abc in ClassA.MethodA(), I also have declared same variable in ClassA.MethodB(). ClassA.MethodA() will call ClassA.Method().
>
>I faced problem that, whenever I have this, program will behave weird, is either take wrong value, or just jump back to calling program without completely execute all necessary code.
>
>Any ideas?
>
>Please advice. Thank you
Each variable are scoped to their bounding blocks (in practice { }). With string abc the 2 variables at different places might be pointing to the same string but since strings are immutable it can't cause a weirdness. IOW once you create a string you can't modify it:
string x = "Hello";
x += " There";
second x is totally a new string.
Cetin