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 constis 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的六种特性 l Strings l Hashs l Lists l Sets l Sorted Sets l Pub/Sub Redis各特性的应用场景 Strings Strings 数据 ...
- ProxyApi-大数据采集用的IP代理池
用于大数据采集用的代理池 在数据采集的过程中,最需要的就是一直变化的代理ip. 自建adsl为问题是只有一个区域的IP. 买的代理存在的问题是不稳定,影响采集效率. 云vps不允许安装花生壳等,即使有 ...
- 15. Linux提取RPM包文件(cpio命令)详解
在讲解如何从 RPM 包中提取文件之前,先来系统学习一下 cpio 命令.cpio 命令用于从归档包中存入和读取文件,换句话说,cpio 命令可以从归档包中提取文件(或目录),也可以将文件(或目录)复 ...
- 【leetcode】43. Multiply Strings(大数相乘)
Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and ...
- 【leetcode】122.Best Time to Buy and Sell Stock II(股票问题)
You are given an integer array prices where prices[i] is the price of a given stock on the ith day. ...
- 【Android】我有放入Icon到mipmap,但不显示,只显示安卓机器人Icon(Android 8.0 图标适配)
首先,放上别人写的博客,而我自己的博客,只会写大概思路,给自己留给备忘 https://blog.csdn.net/guolin_blog/article/details/79417483 其实会发生 ...
- ORACLE profile含义,修改,新增
profiles文件是口令和资源限制的配置集合,包括CPU的时间.I/O的使用.空闲时间.连接时间.并发会话数量.密码策略等对于资源的使用profile可以做到控制会话级别或语句调用级别.oracle ...
- Spring Boot下使用拦截器
Spring Boot对于原来在配置文件配置的内容,现在全部体现在一个类中,该类需要继承自WebMvcConfigurationSupport类,并使用@Configuration进行注解,表示该类为 ...
- 第三届“传智杯”全国大学生IT技能大赛(初赛A组)题解
留念 C - 志愿者 排序..按照题目规则说的排就可以.wa了两发我太菜了qwq #include<bits/stdc++.h> using namespace std; const in ...
- 企业级BI是自研还是采购?
企业级BI是自研还是采购? 上一篇<企业级BI为什么这么难做?>,谈到了企业级BI项目所具有的特殊背景,以及在"破局"方面的一点思考,其中谈论的焦点主要是在IT开发项目 ...