Effiective C # Item1: replace Member variables with attributes

Item1: Always use properties instead of accessible data members Attributes are an important feature in C #. We can use attributes to encapsulate members. From the compiler's point of view, attributes are two methods for member variables: get_xxx

C # const, readonly, static readonly

Const defines a static value that is often assigned during object initialization. It cannot be changed later. It is a compilation constant. New cannot be used for initialization. Readonly is a read-only variable. It is a runtime variable. You can

C # Common exceptions

  Exception: The base class of all Exception objects. Systemexception: The base class of all errors generated during the runtime. Indexoutofrangeexception: It is triggered when the subscript of an array exceeds the range. Nullreferenceexception:

C # interchange between time types and Unix timestamp formats

1. Convert the system time to a Unix Timestamp Datetime dtstart = timezone. currenttimezone. tolocaltime (NewDatetime (1970,1,1));Datetime dtnow = datetime. parse (datetime. Now. tostring ());Timespan tonow = dtnow. Subtract (dtstart

C #3.0 new feature series: implicit type VaR

1. Magic VaR Added a variable declaration VaR in C #3.0, which is similar to the Javascript var, but also different. 1. similarities. It can be used to declare any type of local variables. 2. The difference is that it only tells the

Negative tive C # item13: Use a static constructor to initialize static class members

Before creating any instance of the type, we need to initialize the static member variable of this type. C # can complete this task through the static initialization or static constructor, the static constructor is a special function that is

Negative tive C # item12: The variable initiator is superior to the value assignment statement.

Initialization is recommended when variables are declared because the types we define often have multiple member variables, which leads to multiple constructors, in this way, the member variables and constructors may not be synchronized. We can

Negative tive C # item28: avoid forced type conversion

A layer of replacement is introduced between classes. Replacement means that the instance of one class can be replaced with the instance of another class. For example, in a class hierarchy, where parent classes are used, we can replace them with

Negative tive C # item29: The new modifier is considered only when the new base class is faulty.

We generally use the new modifier on Class Members to redefine non-Virtual members inherited from the base class. However, we do not recommend that you do this, this is because redefinition of non-virtual methods can lead to ambiguous behaviors.

Valid tive C # item44: creates a specific exception class for the Application

An exception is a mechanism for reporting errors. The error processing location may be far from the location where the error occurs. All information about the error cause must be stored in the exception object. In this process, we may want to

Valid tive C # item47: Select security code

The. NET runtime was designed to block the vulnerability of malicious code penetration and execution on remote machines, but some distributed systems always need to download and execute code from remote machines. If the CLR cannot fully trust an

Negative tive C # item31: implement short and concise methods as much as possible

We recommend writing short and concise methods instead of lengthy and complex methods. The main reason is the jit mechanism of. net. When a program written in C # code is running, two steps are required: 1) the C # compiler compiles the source code

Negative tive C # item19: defines and implements interfaces that are better than inheritance types

This topic is not just. net, in other object-oriented language environments, such as Java, there will be interfaces and abstract classes. There have been too many discussions about whether to choose an interface or abstract class, there is a design

C # several methods to Remove string Spaces

1. Regular Expression: system. Text. regularexpressions. RegEx. Replace (STR, "([] + )","")-- STR is the input or string to be checked. 2. Use the string's built-in replace method: Str. Replace ("","")------------- STR is the input or string to be

C # xml operations and C # serialization

For XML: sysproperty. xml   This article mainly introduces two ways to read and modify this XML, The first is reading through xmldocument, and the second is serialized reading.   I. xmldocument method:   1. Read XML and save the attribute name and

C # Implementation of the thread-safe Singleton mode in the database connection pool

This article introduces three thread security Modes 1, lock 2, mutex 3, methodimpl   Previously written MySQL database connection pool connectionpool. CS Using system; using system. collections. generic; using system. LINQ; using system. text; using

C # delegation and event explanation in the vernacular series (2)

What is an event? Event? Click Event? Load events? A series of vague concepts impact our weak head Let's take a look at the more orthodox ideas: An event is a way to provide notifications when something is concerned with it. Generally, events

C # several methods of Thread Synchronization

Summary is very comprehensive, so the full text reproduced, original: http://www.cnblogs.com/michaelxu/archive/2008/09/20/1293716.html During programming, we sometimes use multiple threads to solve the problem. For example, your program needs to

C # delegation and event explanation in the vernacular series (1)

In the preface, you should have a little understanding of the importance of delegation and events. Although we can still be vague, from my vernacular series, I will make these concepts easy to understand. First, let's talk about delegation first.

C # preliminary understanding of delegation, events, anonymous methods, and Lambda

  I learned linqtosql most, pulled lambda expressions, pulled anonymous methods, pulled delegation, and finally involved event processing... Later I found that I did not have a clear understanding of the concept of delegation and the process of

Total Pages: 5902 1 .... 5061 5062 5063 5064 5065 .... 5902 Go to: GO

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.