Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. static void DeclareAndPrintVars(int x)
  2. {
  3. int y = 3;
  4. // Using x and y inside the method is fine.
  5. Console.WriteLine(x + y);
  6. }
  7.  
  8. static void Main()
  9. {
  10. DeclareAndPrintVars(5);
  11.  
  12. // x and y only exist inside the body of DeclareAndPrintVars, so we cannot use them here.
  13. Console.WriteLine(x * y);
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement