1:.net框架的两个主要部分
主要包含公共语言运行时CLR和框架类库(.NET Framework类库,FCL)
2:变量的命名规则
变量名首字母必须为字母,下划线(_),或者美元符号($)开头 命名不能和关键字冲突 同一个变量名不允许重复定义 定义变量名时,变量名要有意义
3.C#程序运行原理(画图)
4.代码举例说明if和switch选择结构
static void Main(string[] args)
{
int a = 4;
int b = 5;
if (a == b)
{
Console.Write("错误");
}
else
{
Console.Write("无");
}
Console.ReadLine();
static void Main(string[] args)
{
int a = 2;
switch (a)
{
case 1: Console.WriteLine("好的");
break;
case 2:
Console.WriteLine("不败之地");
break;
default:
Console.WriteLine("无效的成绩");
break;
}
Console.ReadLine();
}
5.代码举例说明for,while,do-while,foreach四种循环结构
static void Main(string[] args)
{
for (int i = 0; i < 5; i++)
{
Console.WriteLine((i+1)+"遍");
}
Console.ReadLine();
}
static void Main(string[] args)
{
int a = 1;
do
{
Console.WriteLine("一头猪"+a);
a = a + 1;
} while (a<10);
Console.ReadLine();
}
static void Main(string[] args)
{
int[] a = new int[] { 1, 2, 3, 4, 5, 6, 7, 8 };
foreach (var item in a)
{
Console.WriteLine(item);
}
Console.ReadLine();
}
static void Main(string[] args)
{
int a = 10;
while (a < 20)
{
Console.WriteLine("a 的值: {0}", a);
a++;
}
Console.ReadLine();
}
6.四种访问修饰符,并写出访问范围。
public :共有访问,没有任何限制
private:私人访问 ,只限于本类成员,子类,实例都不能访问
protected:保护访问,只限于本类和子类访问,实例不能访问
internal:内部访问,只限于本项目内访问,其他不能访问
7.数据类型有哪两种?并写代码举例和画图说明区别。
值类型:int long float double char bool enum struct
引用类型:object string class interface int[] string[]
8.方法的命名规范
函数和方法的命名应该以动词开始,使用Pascal大写。不要使用带下划线的字符。
9.数组的命名规范
数组的名称由一个美元符号开始,第一个字符是字母或者下划线,标量变量和数组变量不能重名,数组名称区分大小写。