c#捷径教程笔记

 c#捷径教程笔记 第三章c#语法概述

c# 类型和变量

*值类型可以存活于栈或托管堆中。用struct可以定义用户自定义类型。

*值类型与引用类型

值类型:在c#中使用struct关键字定义。值类型的实例是唯一在栈中生存的实例。如果实例是引用

 

类型的成员或是已装箱,它们就生活于堆中,这些内容稍后讨论。当作为参数传入方法或被赋值给

 

其它变量时,默认情况下是以值复制方式进行的,就此而言他们很像c++中的结构。尽管c#的内建值

 

类型与java基本类型很相似,但却不是java的完全对应。

引用类型:在c#中使用class关键字定义。他们之所以被称为引用类型,是因为所使用的这些变量实

 

质上是引用到一个堆上的对象。事实上,在CLR中引用类型变量类似与引用到堆变量的值类型。在这

 

一点上,c3和java是一致的。c++程序员能够把引用类型视为不必解引用去访问对象指针。一些c++

 

程序员乐于把引用类型视作智能指针。

*隐式类型化局部变量

采用var生命隐式类型化局部变量

一个隐含类型的变量的生命必须包括初始化。而且只能出现在局部变量声明中,不能将类成员声明

 

为隐式类型化局部变量。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
C# 2010 offers powerful new features, and this book is the fastest path to mastering them—and the rest of C#—for both experienced C# programmers moving to C# 2010 and programmers moving to C# from another object-oriented language. Many books introduce C#, but very few also explain how to use it optimally with the .NET Common Language Runtime (CLR). This book teaches both core C# language concepts and how to wisely employ C# idioms and object-oriented design patterns to exploit the power of C# and the CLR. This book is both a rapid tutorial and a permanent reference. You'll quickly master C# syntax while learning how the CLR simplifies many programming tasks. You’ll also learn best practices that ensure your code will be efficient, reusable, and robust. Why spend months or years discovering the best ways to design and code C# when this book will show you how to do things the right way from the start? Comprehensively and concisely explains both C# 2008 and C# 2010 features Focuses on the language itself and on how to use C# 2010 proficiently for all .NET application development. Concentrates on how C# features work and how to best use them for robust, high-performance code What you'll learn How C# works with and exploits the CLR How to use arrays, collections, and iterators How to handle events with delegates and anonymous functions How to design and use generic types and methods How to thread efficiently and robustly How C# anonymous types, lamba expressions, and extension methods work and how to use them Who is this book for? If you're an experienced C# programmer, you need to understand how C# has changed with C# 2010. If you're an experienced object-oriented programmer moving to C#, you want to ramp up quickly in the language while learning the latest features and techniques. In either case, this book is for you. The first three chapters succinctly present C# fundamentals, for those new to or reviewing C#. The rest of the book covers all the major C# features, in great detail, explaining how they work and how best to use them. Whatever your background or need, you’ll treasure this book for as long as you code in C# 2010. About the Apress Accelerated Series You already know your industry, but you need to accelerate your skills in a particular area and reach best practices standards in one step. The Apress Accelerated Series of books will ramp you up quickly to industry standards in the area of your choice, by accelerating you through core information and using the professional’s pace to cover best practices and special extras that only a more experienced programmer in the area could give you.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值