C#程序的结构及编写规范(入门到精通)
|
admin
2024年10月1日 13:41
本文热度 965
|
本节要点:
1、第一个C#程序
2、C#程序的结构
3、代码编写规范
一 第一个程序
使用Visual Studio创建C#程序的步骤:

二 C#程序的结构

1 命名空间

2 类
什么是类?
一种数据结构,封装数据成员、函数成员和其他子类,便于调用。
2.1 C# 中类的定义形式:

2.2 类示意图

三 Main方法
Main 首字母大写
返回值可以为 void 或者 int
命令行参数是可选的
语法:

3.1 生活中的"Main"方法

四 标识符

五 关键字

六 注释1

如何让自己海量的代码更可读?
本节要点:
1、第一个C#程序
2、C#程序的结构
3、代码编写规范
4、互动练习1——防微信的全民飞机大战游戏
5、互动联系2——根据经纬度绘制航行轨迹图
6、常见错误
一 第一个程序
使用Visual Studio创建C#程序的步骤:

二 C#程序的结构

1 命名空间

2 类
什么是类?
一种数据结构,封装数据成员、函数成员和其他子类,便于调用。
2.1 C# 中类的定义形式:

2.2 类示意图

三 Main方法
Main 首字母大写
返回值可以为 void 或者 int
命令行参数是可选的
语法:

3.1 生活中的"Main"方法

四 标识符

五 关键字

六 注释1

如何让自己海量的代码更可读?

6.1 为什么需要规范

6.2 代码编写规则

6.3 命名规范
Pascal****命名法:所以单词第一个字母大写,其它字母小写
如 UserId UserName
Camel****命名法:除了第一个单词,所有单词第一个字母大写,其它字母小写
如 userId userName

6.1 为什么需要规范

6.2 代码编写规则

6.3 命名规范
Pascal****命名法:所以单词第一个字母大写,其它字母小写
如 UserId UserName
Camel****命名法:除了第一个单词,所有单词第一个字母大写,其它字母小写
如 userId userName

该文章在 2024/10/2 8:56:01 编辑过