So, in class we are still doing C# tutorials and I am at the second section. I recently finished a tutorial on variable scopes. I feel that variable scopes will come up later in life when I’m coding, so they are very important. I wanted to know more about them and be able to understand them. I went exploring for articles specifically on variable scopes.
I found an article called C# Variable Scopes, which specifically talked about scopes. I learned that a variable’s scope is what controls the visibility of the rest of the code. Most variable are defined in methods, which means the variable's scope is that method, but that’s only once it’s defined. This means that after the method, the variable is ineffective because the code just goes to the next method. I also learned that there are three kinds of scopes. They are method-level, nested, and class. Method-level scopes’ variables are defined inside a method. The variables are only used in that method and can’t be used anywhere else. Nested scopes’ variables can be used out of their code blocks, unlike method-level, which can be used within nested scopes and methods. Class-level scopes’ variables can be used anywhere in the class. Variable Scopes:
Works Cited C# Variable Scopes, www.blackwasp.co.uk/CSharpVariableScopes.aspx.
0 Comments
Leave a Reply. |
AuthorI'm a student at Durham School of the Arts, and currently in the Game Art Design pathway. I like playing the Sims 4, playing with dogs, and riding horses. This blog will reflect my learning and discoveries. Archives
May 2019
Categories
All
|