Zhonghui

每个不曾起舞的日子,都是对生命的辜负

User Tools

Site Tools


程序:csharp:作用域

变量作用域


#include <iostream>
 
int main()
{
    int number = 0;
    {
        int number = 10;
        std::cout<<number<<std::endl;
    }
    std::cout<<number<<std::endl;
}
class MainApp
{
    static void Main()
    {
        int number = 0;
        {
            // Error:
            // A local or parameter named 'number' cannot be declared in this scope because
            // that name is used in an enclosing local scope to define a local or parameter
            int number = 10;
        }
    }
}
/var/www/DokuWikiStick/dokuwiki/data/pages/程序/csharp/作用域.txt · Last modified: 2023/04/03 03:39 by zh