C# 基础(更新中)
Data Structure
There're two types of variables in C#, reference type and value type.
Enum:
enum Color{
Red=0,
Green=1
}
//equals to
enum Color{
Red,//start from 0 as default
Green
}
int to enum:(Color)val
Arrays and Collections
Array
declare array:
new int[10]
new int[10]{xx,xx.....};
new int[]{aa,aa};
Collection
List<string> theList=new List<string>();//can use value type here, not only reference type
theList.Count;//size of the list
class
when calling same name class with different namespace, it will use class of same namespace first, then System
namespace.
fields and properties
- can't use var to declare fields like
var count=0
,must useint count=0
const
is static, so we can't use them together likepublic static const int count=0
- rules of naming fields and property: first letter with uppercase is public, first letter with lowercase is private.
Auto-implemented property: remove their private fields.
initiate with default: public MyClass val {get;set;} = new MyClass();
anonymous type
for the cases:
- only use in one function and not need for other functions
- only exists for only short time, and will be stored to other places
var val=new {name='Alex', age=12};
Extensions
class TheExtensionClass{
public int toInt(this string value){
return int.Parse(value);
}
}
//so that the function can be called on string
str.toInt();
function
out, in and ref
if use out/in/ref
for value type variable, then it will convert to reference type.
must initiate out
variable in the function before use it.
default parameter and named parameter
Default parameter
- must declared after non-default parameter
- if we don't want to give value to the first default parameter but want to give the second default parameter, we can't do this without named parameter
Named parameter:
can call the function and break the sequence of parameters, especially for default parameter
special function:lambda
for the cases:
- short function
var res=theList.Find(MyFunc);
boolean MyFunc(Student aStudent){
return studentName="abc";
}
theList.Find(student=>{
return studentName="abc";
});
theList.Find(student=> studentName="abc");
Event and asynchronous programming
Event
for the cases:
when executing monitor function, it will automatically execute the monitored function
- declare Action variable in class A:
Action action
- binding the action variable to f2 (monitored function) of class B:
action+=f2
- trigger the event: in f3(monitor function) call the action with
action();
### asynchronous programming
like event
RequestSupport(CallBackFunc)
Exception and log
Exception
try{
}catch{
}
try{
}catch(FormatException){
}
try{
}catch(FormatException e){
print e;
print e.Message;
}
Log
C# 基础(更新中)的更多相关文章
- 第一章:大数据 の Linux 基础 [更新中]
本课主题 Linux 休系结构图 Linux 系统启动的顺序 Linux 查看内存和 CPU 指令 环境变量加载顺序 Linux 内存结构 Linux 休系结构图 Linux 大致分为三个层次,第一层 ...
- Unity---UGUI入门基础---更新中
目录 1.UGUI介绍 2.UGUI基础 2.1 Canvas---画布 2.2 Text控件 2.3 Image控件 2.4 RawImage控件 2.5 Button控件 2.6 Toggle控件 ...
- Pig基础学习【持续更新中】
*本文参考了Pig官方文档以及已有的一些博客,并加上了自己的一些知识性的理解.目前正在持续更新中.* Pig作为一种处理大规模数据的高级查询语言,底层是转换成MapReduce实现的,可以作为MapR ...
- Pig语言基础-【持续更新中】
***本文参考了Pig官方文档以及已有的一些博客,并加上了自己的一些知识性的理解.目前正在持续更新中.*** Pig作为一种处理大规模数据的高级查询语言,底层是转换成MapReduce实现的, ...
- java视频教程 Java自学视频整理(持续更新中...)
视频教程,马士兵java视频教程,java视频 1.Java基础视频 <张孝祥JAVA视频教程>完整版[RMVB](东西网) 历经5年锤炼(史上最适合初学者入门的Java基础视频)(传智播 ...
- Android开发面试经——4.常见Android进阶笔试题(更新中...)
Android开发(29) 版权声明:本文为寻梦-finddreams原创文章,请关注:http://blog.csdn.net/finddreams 关注finddreams博客:http:/ ...
- 《WCF技术剖析》博文系列汇总[持续更新中]
原文:<WCF技术剖析>博文系列汇总[持续更新中] 近半年以来,一直忙于我的第一本WCF专著<WCF技术剖析(卷1)>的写作,一直无暇管理自己的Blog.在<WCF技术剖 ...
- 【前端】Util.js-ES6实现的常用100多个javaScript简短函数封装合集(持续更新中)
Util.js (持续更新中...) 项目地址: https://github.com/dragonir/Util.js 项目描述 Util.js 是对常用函数的封装,方便在实际项目中使用,主要内容包 ...
- Linux 系统化学习系列文章总目录(持续更新中)
本页内容都是本人系统化学习Linux 时整理出来的.这些文章中,绝大多数命令类内容都是翻译.整理man或info文档总结出来的,所以相对都比较完整. 本人的写作方式.风格也可能会让朋友一看就恶心到直接 ...
随机推荐
- Redis集合解决大数据筛选
Redis集合:集合是什么,就是一堆确定的数据放在一起,数学上集合有交集.并集的概念,这个就可以用来做大数据的筛选功能. 以商品为例,假如商品有颜色和分类.价格区间等属性. 给所有统一颜色的商品放一个 ...
- 1小时学会Git玩转GitHub
版权声明:原创不易,本文禁止抄袭.转载,侵权必究! 本次教程建议一边阅读一边用电脑实操 目录 一.了解Git和Github 1.1 什么是Git 1.2 什么是版本控制系统 1.3 什么是Github ...
- 使用Redis实现令牌桶算法
在限流算法中有一种令牌桶算法,该算法可以应对短暂的突发流量,这对于现实环境中流量不怎么均匀的情况特别有用,不会频繁的触发限流,对调用方比较友好. 例如,当前限制10qps,大多数情况下不会超过此数量, ...
- 疯了吧!这帮人居然用 Go 写“前端”?(一)
作者 | 郑嘉涛(羣青) 来源 | 尔达 Erda 公众号 无一例外,谈到前后端分离"必定"是 RESTful API,算是定式了.但我们知道 REST 在资源划分上的设计总是 ...
- acid, acknowledge, acquaint
acid sulphuric|hydrochloric|nitric|carbolic|citric|lactic|nucleic|amino acid: 硫|盐|硝|碳|柠檬|乳|核|氨基酸 王水是 ...
- 【STM32】WS2812介绍、使用SPI+DMA发送数据
这篇要使用到SPI+DMA,需要了解的话,可以参考我另两篇博客 时钟:https://www.cnblogs.com/PureHeart/p/11330967.html SPI+DMA通信:https ...
- js将数字转为千分位/清除千分位
/** * 千分位格式化数字 * * @param s * 传入需要转换的数字 * @returns {String} */ function formatNumber(s) { if (!isNaN ...
- 开源低代码开发平台entfrm2.1.0更新
开源低代码开发平台entfrm2.1.0更新 新功能 代码生成支持主子表,支持预览: 新增多应用顶部菜单与左侧菜单联动: element-ui升级到2.15.1: 新增表单管理,集成avue-from ...
- 【Spring Framework】Spring IOC详解及Bean生命周期详细过程
Spring IOC 首先,在此之前,我们就必须先知道什么是ioc,ioc叫做控制反转,也可以称为依赖注入(DI),实际上依赖注入是ioc的另一种说法, 1.谁控制谁?: 在以前,对象的创建和销毁都是 ...
- 使用wesocket从 rabbitMQ获取实时数据
rabbitmq支持stomp组件,通过stomp组件和websocket可以从rabbitMQ获取实时数据.这里分享一个demo: 使用时需要引入的js ,用到了sock.js和stomp.js & ...