C++语言中可以这么用引用,但是C#怎么用啊?谢谢大家!我想看看引用怎么用,已有一个变量a,为这个变量设置一个引用,对引用的操作就相当于对原变量,怎么实现啊?我不想参数传递,就想在程序里实现,能行吗?
namespace 引用
{
class Program
{
static void Main(string[] args)
{
int a = 10;
ref int aa=(int)a;
aa=aa+10;
Console .WriteLine (a);
Console .Read ();
}
}
}
namespace 引用
{
class Program
{
static void Main(string[] args)
{
int a = 10;
ref int aa=(int)a;
aa=aa+10;
Console .WriteLine (a);
Console .Read ();
}
}
}
{
class Program
{
static int a = 10;
static int aa
{
get { return a; }
set { a = value; }
}
static void Main()
{
aa += 10;
System.Console.WriteLine (a);
System.Console.ReadLine();
}
}
}
int &ra=a;
ra=ra+10;
cout<<a<<endl;我就想弄得和C++一样,能吗?还是C#引用本来没有这功能?