c# 基础
freature of c#
Assembly Versioning
Properties and Events
Delegates and Events Management
Indexers
Conditional Compilation
Simple Multithreading
LINQ and Lambda Expressions
namespace
There is no package, but nested namespace instead.
namespace outer { namespace inner { class Demo { // some code here } } }
value type
to get exact size of a type of variable, you can use sizeof method.
reference type
object type
the object type can be assigned values of any other types,
value type
reference type
or user-defined type
object obj;
obj = 100; // this is boxing
dynamic type
you can store any type of value in the dynamic data type variable.
type checking takes place at run-time.
dynamic <variable_name> = value;
dynamic d = 20;
the difference between dynamic type and object type is the time when type checking takes place.
former's type type checking takes place at run-time.
later's type type checking takes place at compile time.
string
The string type is an alias for the System.String class.
It is derived from object type.
There are two forms:
quoted
@quoted
pointer type
pointer in c# have the same capabilities as the pointers in c or c++.
we will discuss pointer types as unsafe codes.
lvalue: An expression that is an lvalue may appear as either the left-hand or right-hand side of an assignment.
rvalue: An expression that is an rvalue may appear on the right- but not left-hand side of an assignment.
array
double[] balance = new double[10]; for (int i = 0; i < 10; i++) { balance[i] = i; } foreach (double d in balance) { Console.WriteLine(d + "\n"); }
structures in c#
struct Books { public string title; public string author; public string subject; public int book_id; };
class versus struct
*classes are reference types and structs are value types
structures do not support inheritance
structures cannot have default constructor
c# has preprocessor directives like in c or c++.
exception handling
try
catch
finally
throw
以上内容均来自 https://www.tutorialspoint.com/csharp/
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· Ollama——大语言模型本地部署的极速利器
· 使用C#创建一个MCP客户端
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· Windows编程----内核对象竟然如此简单?
· ollama系列1:轻松3步本地部署deepseek,普通电脑可用