Win32 API是微软的操作系统Windows提供给开发人员的编程接口,它决定了我们开发的Windows应用程序的能力。MFC是微软为开发人员提供的类库,在某种意义上是对Win32 API的封装。
MFC有一种被称为MFC扩展DLL的共享机制。但是你只能在MFC应用程序中使用它们。
COM提供了一种在不同的应用程序和语言之间共享二进制代码的规范。

C#是一种在.net环境下运行的语言之一。但是.net不只可以用于c#程序的运行,也可以用于其他程序的运行。.net是一个程序运行的环境。

.NET框架
编译工具
产生↓
被编译的代码 使用→ 基类库(BCL)
被执行↓ 被执行↓
公共语言运行库(CLR)

FCL框架类库划分成以下几层。
最内一层,由BCL的大部分组成,主要作用是对.NET框架、.NET运行时及CIL语言本身进行支持,例如基元类型、集合类型、线程处理、应用程序域、运行时、安全性、互操作等。
中间一层,包含了对操作系统功能的封装,例如文件系统、网络连接、图形图像、XML操作等。
最外一层,包含各种类型的应用程序,例如Windows Forms、Asp.NET、WPF、WCF、WF等。

编译过程
.NET兼容语言的源代码文件

.NET兼容编译器

程序集(公共中间语言CIL)(类型信息)(安全信息)

托管代码是.Net框架编写的代码,需要在CLR的环境下运行
非托管代码不在CLR控制之下,比如Win32 C/C++ DLL 成为非托管代码

//命名空间用到为白色,没用到为灰色
//引用命名空间
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

//定义命名空间从{开始,到}结束
namespace _001_Learn_Csharp
{
//定义类
class Program
{
//定义一个Main方法
static void Main(string[] args)
{
//方法体
Console.WriteLine("Hello world");
}
}
}
//ctrl+f5 运行完暂停,不会马上结束

类型库:命名空间(System)---class(Console)---WriteLine()
程序: 命名空间(_001_Learn_Csharp)---class(Program)---Main()

C#命名规则:变量使用驼峰命名,方法和类为每个单词大写

标识符
数字不能放在首位
@字符只能放在标示符的首位

System.Console.Write("Hello world1");
System.Console.WriteLine("Hello world2");
System.Console.WriteLine("两个数相加为{0}+{1}={2}",3,34,37);

0x 或 0X 表示十六进制,0 表示八进制,没有前缀则表示十进制。

用Unicode来表示一个转义字符(\u加上十六进制值) \u0027 为‘

使用@不识别转义字符(除了双引号其他转义字符都不在识别)
使用@可以多行输出
使用@表示路径(string path = "c:\\xxx\\xx\\xxx.doc"; string path =@"c:\xxx\xx\xxx.doc";)

注释(ctrl+k ctrl+c) 取消注释(ctrl+k ctrl+u)

int hp,mp=90,exp=50;
第一次给变量赋值叫做初始化

浮点数在计算机中用以近似表示任意某个实数。具体的说,这个实数由一个整数或定点数(即尾数)乘以某个基数(计算机中通常是2)的整数次幂得到,这种表示方法类似于基数为10的科学记数法。

001
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace test_001
{
class Program{
static void Main(string[] args)
{
string name = "cai";
int hp = 100;
int level = 34;
float exp = 345.3f;
Console.WriteLine("主角的名字是:{0}\n血量:{1}\n等级:{2}\n经验值:{3}", name, hp, level, exp);
string str1 = "I'm a good man.You are bad gril!";
Console.WriteLine(str1);
string str2 = @"I'm a good man.\n You are bad gril!";
Console.WriteLine(str2);
Console.ReadKey();

}
}
}

02
string str1 = Console.ReadLine();
int num1 = Convert.ToInt32(str1);
string str2 = Console.ReadLine();
int num2 = Convert.ToInt32(str2);
int temp = num1;
num1 = num2;
num2 = num1;
Console.WriteLine(num1+":"+num2);
Console.ReadKey();

类型之间的转换
string locstr = 123.ToString();//如果要将"locstr"转成整型数int i =Convert.ToInt16(locstr);
//方法一: 用 Convert int ii = int.Parse(locstr)
//方法二: 用 Parse

double dnum = 100.1;int ifromd = (int)dnum; //double类型显式转换转为int类型Class1 c11 = new Class1();Class2 c22 = c11as Class2; //使用as进行显式转换

goto
int myInteger = 5;
goto mylabel;//goto语句用来控制程序跳转到某个标签的位置
myInteger++;
Console.WriteLine(myInteger);
Console.ReadKey();

循环的中断 break(终止当前循环)
循环的中断 continue(终止当前循环继续下一个循环)
循环的中断 return 跳出循环(跳出函数)

枚举
枚举类型的定义
enum <typeName>{
<value1>,
<value2>,
<value3>,
...
<valueN>
}
枚举类型的声明 <typeName> <varName>;
枚举类型的赋值<varName>=<typeName>.<value>;

enum GameState{
Pause,
Failed,
Success,
Start
}
在游戏中定义一个 GameState state = GameState.Start;
class Program{
static void Main(stirng)
}

结构体
如果我们要表示一个向量的话 需要定义,三个float类型 x y z
这样比较麻烦,不方便管理,我们可以使用结构
定义结构
struct <typeName>{
<memberDeclarations>
}
其中<memberDeclarations>是结构体的成员,每个成员的声明如下
<type> <name>;
struct Vector3{
float x;
float y;
float z;
}

——类是引用类型,结构是值类型。
——结构不支持继承。
——结构不能声明默认的构造函数。

数组
数组是一个存储相同类型元素的固定大小的顺序集合。数组是用来存储数据的集合,通常认为数组是一个同一类型变量的集合。
int[] scores;
第一种方式
scores ={34,34,3,43,43,4,34};
第二种方式
scores = new int[10]; 里面的每一个元素按照类型的默认值赋值
第三种方式
scores = new int[10]{123,12,34,56,77,89,85,6,45634,34};
数组的访问
<arrayName>[条目索引]

int [] shuzhu = new shuzhu[5] { 99, 98, 92, 97, 95}
foreach(int j in shuzhu ) { int i = j-100; Console.WriteLine("Element[{0}] = {1}", i, j); } Console.ReadKey();

多维数组
string [,] names;

交叉数组
int[][] scores = new int[2][]{new int[]{92,93,94},new int[]{85,66,87,88}};

参数数组 params
public 返回类型 方法名称( params 类型名称[] 数组名称 )

字符串
ToLower() 转化小写
ToUpper() 转化大写
Trim()去掉字符串前面或者后面空格
TrimStart()
TrimEnd()
Split('.') 把字符串按照指定的字符进行拆分,得到数组

委托
using System;
using System.IO;
namespace DelegateAppl{
class PrintString {
static FileStream fs;
static StreamWriter sw; // 委托声明
public delegate void printString(string s); // 该方法打印到控制台
public static void WriteToScreen(string str) {
Console.WriteLine("The String is: {0}", str);
} // 该方法打印到文件
public static void WriteToFile(string s) {
fs = new FileStream("c:\\message.txt", FileMode.Append, FileAccess.Write);
sw = new StreamWriter(fs);
sw.WriteLine(s);
sw.Flush();
sw.Close();
fs.Close();
} // 该方法把委托作为参数,并使用它调用方法
public static void sendString(printString ps)
{
ps("Hello World");
}
static void Main(string[] args) {
printString ps1 = new printString(WriteToScreen);
printString ps2 = new printString(WriteToFile);
sendString(ps1);
sendString(ps2);
Console.ReadKey();
}
}
}

【SIKIA计划】_03_C#初级教程 (2015版)笔记的更多相关文章

  1. 【SIKIA计划】_04_C#中级教程 (2015版)笔记

    IKIC#中级教程 (2015版)正常模式指的是不会影响程序的正常运行.1,在VS中我们使用Console.Write(或者WriteLine)方法向控制台输出变量的值,通过这个我们可以查看变量的值是 ...

  2. 【SIKIA计划】_11_Unity动画插件-DOTween笔记

    [插值移动]using DG.Tweening;public class GetStart:MomoBehaviour{ public Vector3 myValue = new Vector3(0, ...

  3. 【SIKIA计划】_10_Unity5.1UI系统-UGUI笔记

    Canvas——TextEventSystem 事件系统 0.滚动文本列表(隐藏背景)/Scroll/maskimage[Scroll Rect][Mask]——text(拉伸到显示全部)Scroll ...

  4. Backbone.js入门教程第二版笔记(3)

    视图渲染 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <titl ...

  5. Backbone.js入门教程第二版笔记(2)

    关于手动触发router,之前看到的例子都是通过在url后面加上#xxx或者点击一个a链接方法来触发, 还有一种情况是通过触发一种规则,来触发另一种规则(表述无能),比如这个例子中,我在url后面加上 ...

  6. Backbone.js入门教程第二版笔记(1)

    1.模块 集合 视图 和事件的一个综合例子 <!DOCTYPE html> <html> <head> <meta charset="UTF-8&q ...

  7. [转]Android 学习资料分享(2015 版)

    转 Android 学习资料分享(2015 版) 原文地址:http://www.jianshu.com/p/874ff12a4c01 目录[-] 我是如何自学Android,资料分享(2015 版) ...

  8. Mac OS X Terminal 101:终端使用初级教程

    Mac OS X Terminal 101:终端使用初级教程 发表于 2012 年 7 月 29 日 由 Renfei Song | 文章目录 1 为什么要使用命令行/如何开启命令行? 2 初识Com ...

  9. [初级教程]用SecureCRT+Xming轻松远程实现Linux的X DISPLAY

    [初级教程]用SecureCRT+Xming轻松远程实现Linux的X DISPLAY 发布者:sqqdugdu 时间:10-06 阅读数:2117 测试环境:RHEL 6.1,SecureCRT 5 ...

随机推荐

  1. EclEmma安装与使用

    安装 EclEmma 插件的过程和大部分 Eclipse 插件相同,我们既可以通过 Eclipse 标准的 Update 机制来远程安装 EclEmma 插件(图 1),也可以从站点(参阅参考资源)下 ...

  2. 解决Struts2 json-plugin Date或Timestamp等日期格式带T的问题

    如果没有对日期时间对象类进行json日期格式声明,会出现类似"2013-06-18T12:08:56.23"日期,在日期中间多出一个T字母: 从通过查询数据,以及调试程序发现直到返 ...

  3. Sublime Text 3中文乱码

    Sublime Text 3是很好的代码编辑器,没有之一,因为她的性感高亮代码配色,更因为它的小巧,但是它默认不支持GBK的编码格式,因此打开GBK的代码文件,如果里面有中文的话,就会乱码,如下所示: ...

  4. Python 2.7和3.6爬取妹子图网站单页测试图片

    1.url= http://www.mzitu.com/74100/x,2为1到23的值 2.用到模块 os 创建文件目录; re模块正则匹配目录名 图片下载地址; time模块 限制下载时间;req ...

  5. Opencv——级联分类器(AdaBoost)

    API说明: cv::CascadeClassifier::detectMultiScale(InputArray image,//输入灰度图像 CV_OUT std::vector<Rect& ...

  6. assignment1SVM的一些经验

    def svm_loss_vectorized(W, X, y, reg): """ Structured SVM loss function, vectorized i ...

  7. CS231N assignment1

    # Visualize some examples from the dataset. # We show a few examples of training images from each cl ...

  8. POJ 3356 水LCS

    题目链接: http://poj.org/problem?id=3356 AGTC Time Limit: 1000MS   Memory Limit: 65536K Total Submission ...

  9. 关于java8(Stream)的一些用法

    如果要处理int[] 转换成 List<Integer>这种形式的,可以用下面这个方法: List<Integer> orgIds = Arrays.stream(reqVo. ...

  10. 轻松构建 基于docker的 redis 集群

    下面跟着我来 一步一步构建redis 集群吧. 集群的目录结构见GitHub源码(文章末尾) 1,安装docker环境,根据自身的操作系统,google下即可. 2,我们在服务器上,搭建所需目录结构. ...