1:.net框架的两个主要部分
CLR和FCL
2:变量的命名规则
变量名首字母必须为字母(a-z A-Z),下划线(_),或者美元符号($)开始,并且之间不能包含空格。
3:C#程序运行原理(画图)
4:代码举例说明if和switch选择结构
//if选择
Console.WriteLine("请您输入成绩:");
int sc = int.Parse(Console.ReadLine());
int a = sc;
if (a > 100 | a < 0)
{
Console.WriteLine("您输入的成绩有误!");
}
else if (a >= 90 & a <= 100)
{
Console.WriteLine("A等");
}
else
{
Console.WriteLine("您输入的成绩有误");
}
//switch
Console.WriteLine("请您输入要转换的星期数:");
int week = int.Parse(Console.ReadLine());
switch (week)
{
case 1:
Console.WriteLine("星期1");
break;
case 2:
Console.WriteLine("星期2");
break;
default:
Console.WriteLine("您输入的数字有误, 请重新输入");
break;
}
5:代码举例说明for,while,do-while,foreach四种循环结构
//for循环
Console.Write("请输入一个正整数:");
int a = int.Parse(Console.ReadLine());
int sum = 0;
for (int i = 1; i <= a; i++)
{
sum=sum+i;
}
Console.WriteLine(sum);
Console.ReadLine();
//do...while循环
int a = 10;
do
{
Console.WriteLine("a 的值: {0}", a);
a = a + 1;
} while (a == 100);
Console.ReadLine();
//while循环
int a = 10;
while (a < 20)
{
Console.WriteLine("a 的值: {0}", a);
a++;
}
Console.ReadLine();
//foreach循环
double[] points = { 80, 88, 86, 90, 75.5 };
double sum = 0;
double avg = 0;
foreach(double point in points)
{
sum = sum + point;
}
avg = sum / points.Length;
Console.WriteLine("总成绩为:" + sum);
Console.WriteLine("平均成绩为:" + avg);
6:四种访问修饰符,并写出访问范围。
权限 | 同类 | 同包 | 字类 | 其他包 |
public | √ | √ | √ | √ |
private | √ | × | × | × |
protect | √ | √ | √ | × |
default | √ | √ | × | × |
public:任何地方都可以访问到;
protected:只有其内部或其派生的类型能访问;
internal:只能在包含它的程序集中可以访问;
private:只能在它所属的类型中可以访问;
7:数据类型有哪两种?并写代码举例和画图说明区别。
值类型和引用类型
//值类型
int heightzhong = 170;
int heightli = heightzhong ;
Console.WriteLine("去年张浩身高"+heightzhong +",李明身高+"heightli);
heightli = 175;
Console.WriteLine("今年张浩身高"+heightzhong+",李明身高+heightli);
Console.ReadKey();
//引用类型
int[] zhang = new int[] { 170 };
int[] li = zhang;
Console.WriteLine("张三的身高是:"+zhang[0]);
Console.WriteLine("李四的身高是:"+li[0]);
li[0] = 180;
Console.WriteLine("张三的身高是:"+ zhang[0]);
Console.WriteLine("李四的身高是:" + li[0]);
8:方法的命名规范。
函数和方法的命名应该以动词开始,使用Pascal大写。不要使用带下划线的字符。
9:数组的命名规范。
数组的名称由一个美元符号开始,第一个字符是字母或者下划线,标量变量和数组变量不能重名,数组名称区分大小写。