title: Using ref to pass delegate
body: <p>Delegate are reference type but still when trying to pass it to a method it requires a ref keyword.</p>
  
  <p>This reminds me of string that requires ref to be modified within a method because they are immutable, are delegate immutable?</p>
  
  <p>Here is my mini project:</p>
  
  <pre><code>delegate void MyDel();
  static void Main(string[] args)
  {
      MyDel _del  = new MyDel(Idle);
  
      while(true)
      {
          if(_del != null)
              _del();  
              int c = Console.Read();
              AI(c,ref _del);
              Console.Read();
              Console.Read();
          }
      }
  }
      static void AI(int c, ref MyDel del) 
      {
          if(c == 'a')
          {
              del = Attack;
          }else if(c == 'i'){
              del = Idle;
          }else if (c == 's'){
              del = SwingSword;
          }
          else if (c == 'w')
          {
              del = Attack;
              del += SwingSword;
          }
          else {
              del = Idle;
          }
      }
  </code></pre>
  
  <p>Without the ref keyword I am back to the swap method case where things happen only inside the method.</p>
  
  <p>Can anyone tell me why delegates need to be passed by reference?</p>