Advertisement
Guest User

test

a guest
Aug 11th, 2016
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.13 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 ConsoleApplication16
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var collection = new List<int>
  14.             {
  15.                 5, 6, 7, 8, 9, 10
  16.             };
  17.  
  18.             Test(collection);
  19.  
  20.             foreach(var value in collection)
  21.             {
  22.                 Console.WriteLine(value);
  23.             }
  24.  
  25.             var result = new List<int>
  26.             {
  27.                 5, 6, 7, 8, 9, 10
  28.             };
  29.  
  30.             try
  31.             {
  32.                 Test(ref result);
  33.  
  34.                 foreach (var value in result)
  35.                 {
  36.                     Console.WriteLine(value);
  37.                 }
  38.             } catch(Exception ex)
  39.             {
  40.                 Console.WriteLine(ex.Message);
  41.             }
  42.         }
  43.  
  44.         static void Test(List<int> collection)
  45.         {
  46.             collection = null;
  47.         }
  48.  
  49.         static void Test(ref List<int> collection)
  50.         {
  51.             collection = null;
  52.         }
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement