DuskXtremeX

C# Understanding Scopes

Jun 25th, 2014
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.35 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace UnderstandingScope
  8. {
  9.     class Program
  10.     {
  11.         //private static string k = "";
  12.         static void Main(string[] args)
  13.         {
  14.            /*
  15.             string j = "";
  16.             for (int i = 0; i < 12; i++)
  17.             {
  18.                 j = i.ToString();
  19.                 k = i.ToString();
  20.                 Console.WriteLine(i);
  21.  
  22.                 if(i == 9)
  23.                 {
  24.                     string l = i.ToString();
  25.                 }
  26.                 //Console.WriteLine(l);
  27.             }
  28.             //Console.WriteLine(i);
  29.             Console.WriteLine("Outside of for loop : "+ j);
  30.             //Console.WriteLine("K = " + k);
  31.             helpermethod();
  32.             */
  33.             Car car = new Car();
  34.  
  35.             car.DoSomething();
  36.             Console.ReadLine();
  37.         }
  38.         /*
  39.         static void helpermethod()
  40.         {
  41.             Console.WriteLine("K From helpermethod : " + k);
  42.         }
  43.          */
  44.  
  45.         class Car
  46.         {
  47.            public void DoSomething()
  48.             {
  49.                Console.WriteLine(helperMethod());
  50.             }
  51.             private string helperMethod()
  52.             {
  53.                 return "Hello World";
  54.             }
  55.         }
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment