📄 const.cs
字号:
using System;
class MyClass
{
public static void swap(ref int m1,ref int n1)//交换了m和n的值
{
int temp=m1;
m1=n1;
n1=temp;
}
public static int area(int m,int n)
{
int a=m*n;
return a;
}
public static void Main()
{
int m=1;
int n=2;
const int a=3;
//const static int a=3;错误,不能用static修饰
//a=4;试图改变常量的值,错误
const int b=a+1;//常量出现在常量表达式中
Console.WriteLine("The value of m is:{0}",m);
Console.WriteLine("The value of n is:{0}",n);
Console.WriteLine("The value of a is:{0}",a);
Console.WriteLine("The value of b is:{0}",b);
Console.WriteLine("change the value of m and n......");
Console.WriteLine("please input the value of m:");
string s=Console.ReadLine();
m=int.Parse(s);
Console.WriteLine("please input the value of n:");
string s1=Console.ReadLine();
n=int.Parse(s1);
Console.WriteLine("now m={0},n={1}",m,n);
swap(ref m,ref n);
Console.WriteLine("swap m and n......");
Console.WriteLine("now the value of m is:{0}",m);
Console.WriteLine("now the value of n is:{0}",n);//m和n的值改变
//swap(ref a,ref b);错误
int area1=area(a,b);
Console.WriteLine("a*b={0}",area1);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -