Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void DeclareAndPrintVars(int x)
- {
- int y = 3;
- // Using x and y inside the method is fine.
- Console.WriteLine(x + y);
- }
- static void Main()
- {
- DeclareAndPrintVars(5);
- // x and y only exist inside the body of DeclareAndPrintVars, so we cannot use them here.
- Console.WriteLine(x * y);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement