C#中使用引用作为函数参数

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Threading.Tasks;

//json
using System.Web.Script.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Data.SqlClient;

namespace csharpTest
{
    /// 
    /// class program类
    /// 
    class Program
    {
        static void Main(string[] args)
        {
            int x = 5;
            int y = 6;
            swap(ref x, ref y);
            Console.WriteLine(x);
            Console.WriteLine(y);
            Console.ReadLine();
        }

        static public void swap(ref int x, ref int y)
        {
            int temp;
            temp = x;
            x = y;
            y = temp;
        }
    }
}

 

你可能感兴趣的:(C#)