What is the difference between a member variable and a local variable?

前端 未结 7 748
再見小時候
再見小時候 2020-11-29 08:01

What is the difference between a member variable and a local variable?

Are they the same?

相关标签:
7条回答
  • 2020-11-29 08:50
    public class Foo
    {
        private int _FooInt; // I am a member variable
    
    
        public void Bar()
        {
           int barInt; // I am a local variable
           //Bar() can see barInt and _FooInt
        }
    
        public void Baz()
        {
           //Baz() can only see _FooInt
        }
    }
    
    0 讨论(0)
提交回复
热议问题