Advertisement
Guest User

Untitled

a guest
Nov 21st, 2011
817
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.66 KB | None | 0 0
  1. static void Main()
  2.         {
  3.             List<String> str = new List<string>() { "a", "b", "c" };
  4.  
  5.             Method(str);
  6.             foreach (var item in str)
  7.             {
  8.                 Console.WriteLine(item);
  9.             }
  10.             Method1(ref str);
  11.  
  12.             foreach (var item in str)
  13.             {
  14.                 Console.WriteLine(item);
  15.             }
  16.  
  17.             Console.ReadLine();
  18.         }
  19.  
  20.         private static void Method1(ref List<string> str)
  21.         {
  22.             str.Add("d");
  23.         }
  24.  
  25.         private static void Method(List<string> str)
  26.         {
  27.             str = new List<string>() { "1", "2", "3" };
  28.         }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement