LeetCode 4 Median of two sorted arrays

Given two sorted arrays nums1 and nums2 of size m and n respectively, 
return the median of the two sorted arrays.
 

        public double LeetCode_4(int[] nums1, int[] nums2)
        {
            double ans = 0;
            int m = nums1.Length, n = nums2.Length;
            int[] nums3 = new int[m + n];
            int buf = 0;

            for (int i = 0; i < m; i++)
                nums3[i] = nums1[i];
            for (int i = 0; i < n; i++)
                nums3[i + m] = nums2[i];

            for (int i = 0; i < (m + n); i++)
            {
                for (int j = i; j < (m + n); j++)
                {
                    if (nums3[i] > nums3[j])
                    {
                        buf = nums3[j];
                        nums3[j] = nums3[i];
                        nums3[i] = buf;
                    }
                }
            }

            if ((m + n) % 2 == 0)
            {
                ans = (nums3[(m + n) / 2 - 1] + nums3[(m + n) / 2]);
                ans = ans / 2;
            }
            else
            {
                ans =  nums3[(m + n) / 2];
            }

            return ans;
        }