I am new with C# and I can't understand why this code doesn't work.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] sw = "ab".ToCharArray();
            swap(sw[0], sw[1]);
            string end = new string(sw);
            Console.Write(end);
        }
        static void swap(char a, char b)
        {
            char temp = a;
            a = b;
            b = temp;
        }
    }
}
What I expect on console is "ba" but I get "ab". I was able to find different approach to solve this problem but what I would like to know is what is the mistake in this code. Thanks for the help!
 
     
     
     
     
     
    