100个c#初学者编程实例_C#编程:初学者⼊门
100个c#初学者编程实例
C Sharp, more commonly referred to as “C#”, is a general-purpose, -oriented programming language. C# was developed by Anders Hejlsberg and his development team at Microsoft and is currently on version 7.0.
C Sharp,通常称为“ C#”,是⼀种通⽤的,⾯向对象的编程语⾔。 C#由Anders Hejlsberg及其Microsoft的开发团队开发,当前版本为7.0。
C# has its roots in the family of C languages. It inherits most of its features from C, C++, and Java. For this reason, programmers familiar with these languages may be able to get up to speed with C# in a shorter time span.
C#起源于C语⾔家族。 它继承了C,C ++和Java的⼤部分功能。 因此,熟悉这些语⾔的程序员可能能够在较短的时间范围内熟悉C#。
C# is an object-oriented language that provides support for component-oriented and functional programming.
C#是⼀种⾯向对象的语⾔,为⾯向组件和功能的编程提供⽀持。
类和对象 (Classes and Objects)
Classes allow us to model everyday objects in the world around us in software. You can create custom classes to represent just about anything. Just like a noun is a person, place or thing in language, so too, a classes represents objects.
通过类,我们可以使⽤软件对周围世界中的⽇常对象进⾏建模。 您可以创建⾃定义类来表⽰⼏乎所有内容。 就像名词是语⾔中的⼈,地⽅或事物⼀样,类也表⽰对象。
安卓开发实例入门
When you write C# code, typically it is because you need a program that does something useful.
编写C#代码时,通常是因为您需要⼀个程序来做⼀些有⽤的事情。
In the case of a business need, you follow requirements that the business needs. Say your business comes to you asks you for an electronic database of books. They need to be able to store book titles, authors, compute statistics, like the number
of checkouts in a given month, or a monthly average.
在业务需要的情况下,请遵循业务需要的要求。 说您的⽣意来了,您要求您提供电⼦图书数据库。 他们需要能够存储书名,作者,计算统计信息,例如给定⽉份或每⽉平均值的结帐次数。
The requirements describe the program that needs to be developed. How do you write a program for the given requirements?
需求描述了需要开发的程序。 您如何针对给定的要求编写程序?
Generally, we use classes to create abstractions for the different nouns that we need to work with. A noun such as a book, author, or title.
通常,我们使⽤类为需要使⽤的不同名词创建抽象。 名词,如书,作者或标题。
An important concept in C# is that the class definition is used to create instances of objects. You can think of it like a blueprint for creating instances of objects. The class definition allows the creation of objects that store a reference to that object. For example, say we want to create a new book object. The line of code looks like this:
C#中的⼀个重要概念是类定义⽤于创建对象的实例。 您可以将其视为创建对象实例的蓝图。 类定义允许创建存储对该对象的引⽤的对象。 例如,假设我们要创建⼀个新的书本对象。 代码⾏如下所⽰:
Book book = new Book();
This creates a new book object that we can use to manipulate data and store it in a database. The variable, book, is actually a reference type of Book (with a capital B). We can then use methods available in the class definition with that variable, book, such as AddTitle(), AddAuthor(), and so on.
这将创建⼀个新的书本对象,我们可以使⽤它来处理数据并将其存储在数据库中。 变量book实际上是Book的引⽤类型(⼤写字母B)。 然后,我们可以使⽤与该变量,书类定义可⽤的⽅法,如AddTitle()AddAuthor()等等。
C#的功能包括: (Features of C# include:)
1. Automatic Garbage Collection
⾃动垃圾收集
2. Exception Handling
异常处理
3. Type-safety
类型安全
4. Versioning
版本控制
5. Delegates
代表们
6. Properties
物产
7. LINQ (Language-Integrated Query) and Lambda Expressions
LINQ(语⾔集成查询)和Lambda表达式
8. Generics
泛型
9. Indexers
索引器
10. Multithreading
多线程
C#7.0中添加的新功能: (New Features Added in C# 7.0:)
1. Deconstructors
解构函数
2. New syntax to work with Tuples
与元组⼀起使⽤的新语法
3. Pattern Matching with Is Expressions
与Is表达式进⾏模式匹配
4. Local Functions
局部功能
5. Return by Reference
参考归还
6. Out Variables
输出变量
7. Literal improvements
字⾯改进
8. Generalized Async Return Types
⼴义异步返回类型
9. More Expression-Bodied Members
更多表情包成员
10. Throw Expressions
投掷表达式
11. Record Type
记录类型
12. Minimizing OUT
最⼩化输出
13. Non-‘NULL’ able reference type
不能为“ NULL”的引⽤类型
ASP.NET和.NET应⽤程序 (ASP.NET and .NET Applications)
The C# language is also used with the ASP.NET framework, developed by Microsoft Corp., specifically for creating web applications that are machine and browser independent.
C#语⾔还与Microsoft Corp.开发的ASP.NET框架⼀起使⽤,专门⽤于创建与计算机和浏览器⽆关的Web应⽤程序。
The broader .NET framework, also developed by Microsoft, is used for creating other types of applications such as desktop, mobile, server, and networking applications. The .NET framework includes the .NET Base Class Libraries (BCL), ASP.NET, ADO.NET, Windows Forms, Windows Presentation Foundation (WPF), and eXtensible Markup Language(XML) libraries.
也由Microsoft开发的更⼴泛的.NET框架⽤于创建其他类型的应⽤程序,例如桌⾯,移动,服务器和⽹络应⽤程序。 .NET框架包括.NET基类库(BCL),ASP.NET,ADO.NET,Windows窗体,Windows Presentation Foundation(WPF)和可扩展标记语⾔(XML)库。
100个c#初学者编程实例

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。