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

  1. can't use var to declare fields like var count=0,must use int count=0
  2. const is static, so we can't use them together like public static const int count=0
  3. 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

  1. declare Action variable in class A:Action action
  2. binding the action variable to f2 (monitored function) of class B:action+=f2
  3. 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# 基础(更新中)的更多相关文章

  1. 第一章:大数据 の Linux 基础 [更新中]

    本课主题 Linux 休系结构图 Linux 系统启动的顺序 Linux 查看内存和 CPU 指令 环境变量加载顺序 Linux 内存结构 Linux 休系结构图 Linux 大致分为三个层次,第一层 ...

  2. Unity---UGUI入门基础---更新中

    目录 1.UGUI介绍 2.UGUI基础 2.1 Canvas---画布 2.2 Text控件 2.3 Image控件 2.4 RawImage控件 2.5 Button控件 2.6 Toggle控件 ...

  3. Pig基础学习【持续更新中】

    *本文参考了Pig官方文档以及已有的一些博客,并加上了自己的一些知识性的理解.目前正在持续更新中.* Pig作为一种处理大规模数据的高级查询语言,底层是转换成MapReduce实现的,可以作为MapR ...

  4. Pig语言基础-【持续更新中】

      ***本文参考了Pig官方文档以及已有的一些博客,并加上了自己的一些知识性的理解.目前正在持续更新中.***   Pig作为一种处理大规模数据的高级查询语言,底层是转换成MapReduce实现的, ...

  5. java视频教程 Java自学视频整理(持续更新中...)

    视频教程,马士兵java视频教程,java视频 1.Java基础视频 <张孝祥JAVA视频教程>完整版[RMVB](东西网) 历经5年锤炼(史上最适合初学者入门的Java基础视频)(传智播 ...

  6. Android开发面试经——4.常见Android进阶笔试题(更新中...)

      Android开发(29)  版权声明:本文为寻梦-finddreams原创文章,请关注:http://blog.csdn.net/finddreams 关注finddreams博客:http:/ ...

  7. 《WCF技术剖析》博文系列汇总[持续更新中]

    原文:<WCF技术剖析>博文系列汇总[持续更新中] 近半年以来,一直忙于我的第一本WCF专著<WCF技术剖析(卷1)>的写作,一直无暇管理自己的Blog.在<WCF技术剖 ...

  8. 【前端】Util.js-ES6实现的常用100多个javaScript简短函数封装合集(持续更新中)

    Util.js (持续更新中...) 项目地址: https://github.com/dragonir/Util.js 项目描述 Util.js 是对常用函数的封装,方便在实际项目中使用,主要内容包 ...

  9. Linux 系统化学习系列文章总目录(持续更新中)

    本页内容都是本人系统化学习Linux 时整理出来的.这些文章中,绝大多数命令类内容都是翻译.整理man或info文档总结出来的,所以相对都比较完整. 本人的写作方式.风格也可能会让朋友一看就恶心到直接 ...

随机推荐

  1. Linux 中的五种 IO 模型

    Linux 中的五种 IO 模型 在正式开始讲Linux IO模型前,比如:同步IO和异步IO,阻塞IO和非阻塞IO分别是什么,到底有什么区别?不同的人在不同的上下文下给出的答案是不同的.所以先限定一 ...

  2. Office2020-2021 离线安装教程

    首先:先安装两个 net .再安装 office 如下: DownFile:https://pan.baidu.com/s/19iykxwofXK36wWY5w4GVFg  codenum:6666

  3. 大厂高频面试题Spring Bean生命周期最详解

    Spring作为当前Java最流行.最强大的轻量级框架.Spring Bean的生命周期也是面试高频题,了解Spring Bean周期也能更好地帮助我们解决日常开发中的问题.程序员应该都知道Sprin ...

  4. REMI源安装php7.3

    参考:https://blog.csdn.net/Phplayers/article/details/100901352 php5.6安装参考:https://www.cnblogs.com/Easo ...

  5. Linux FTP的主动模式与被动模式

    Linux FTP的主动模式与被动模式 一.FTP主被动模式        FTP是文件传输协议的简称,ftp传输协议有着众多的优点所以传输文件时使用ftp协议的软件很多,ftp协议使用的端口是21( ...

  6. [学习总结]2、android中的VelocityTracker(获得速率用的类)

    参考资料:http://blog.jrj.com.cn/4586793646,5298605a.html 感谢这位兄弟! android.view.VelocityTracker主要用跟踪触摸屏事件( ...

  7. Linux lvm在线扩容

    1.查看磁盘空间 [root@bgd-mysql3 ~]# fdisk -l Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 sector ...

  8. binlog2sql 解析日志失败 UnicodeDecodeError: 'utf-8' codec can't decode byte 0xba in position 0: invalid start byte

    python35 ./binlog2sql.py -h... -P... -u... -p... -B --start-file="mysql-bin.091940" --star ...

  9. 【Linux】【Commands】基础概念及常用基础命令

    命令的语法通用格式: ------------------------------------------------ #COMMAND OPTIONS ARGUMENTS 发起命令:请求内核将某个二 ...

  10. 阿里云esc 登录时的相关提示

    1. 如果该ecs 未绑定密钥对,可以通过常规的用户名密码登录 2. 如果该 ecs 绑定了密钥对,则需要通过私钥进行登录 3. 如果使用 比如 securityCRT 登录时报 " A p ...