Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ C # Future: Tracking null reference     - About Nginx 7 (Server)

- exp / imp Export Import version of the problem and the ORA-6550 error (Database)

- Linux system Passwd file detailed analysis (Linux)

- How to extend / remove swap partitions (Linux)

- Gentoo: !!! existing preserved libs problem (Linux)

- SYN attack hacker attack and defense of the basic principles and prevention technology (Linux)

- Timing Nginx logs cut and remove the log records of the specified number of days before (Server)

- Comparison of sorting algorithms (Programming)

- How do I cancel (almost) any operations in Git, (Linux)

- Terminal Linux command prints - echo (Linux)

- RHEL5.8 physical opportunities to Read-only file system (Linux)

- Installation and configuration of Hadoop under Linux (Server)

- Hibernate Performance Optimization of reusing SessionFactory (Programming)

- SQLite database commonly used sentences and visualization tools on MAC MeasSQLlite use (Database)

- To install the mail client terminal Evolution 3.13.2 under Ubuntu 14.04 (Linux)

- Linux Beginner Guide: Installing packages on Ubuntu and Fedora (Linux)

- Applications in Objective-C runtime mechanism (Programming)

- JavaScript: understanding regular expressions (Programming)

- C # asynchronous delegates (Programming)

- Configuring xdebug debugging environment in Ubuntu 14.04 under the PhpStorm (Linux)

 
         
  C # Future: Tracking null reference
     
  Add Date : 2018-11-21      
         
         
         
  In .NET the most common types of errors probably the number of null reference exception. This error is rooted in C # can not express the concept of non-null reference, which also leads to allow the compiler to force a blank check into an overly burdensome task.

To address this problem, a proposal shall recommend the use of a mandatory reference, and define a clear reference may be empty. In the proposal, you can use null reference? Suffixes are defined as nullable value types are defined the same way. Compulsory reference, or non-null reference will use the! Suffix definitions.

Enforces referential and a null reference should be viewed as a concept limited to the language itself, they just changed the behavior of the compiler, but does not change the generated IL code.

Before the compiler allows access to any method or property can be null reference object, you must explicitly check the null reference. And the transition to a null reference can enforce referential before, must also be null reference checks.

The compiler enforces referential need to confirm the value contained therein is not empty. Since this rule is limited to one kind of compiler can not be guaranteed in the reverse sequence and so the scene can be similarly effective.

After reading the full content of this proposal, you will notice a term which refers to the "general reference." It refers to C # in general reference is neither mandatory nor clearly defined as empty. Since this reference is treated as legacy code, so you can tell the compiler by AllowGeneralReferences This attribute is generally referenced in the code are not allowed.

When combined with the implicit variable definition can be used in the var keyword! Or? suffix.

Type Conversion

According to this proposal, you can implicitly converted to a mandatory reference to a null reference. However, it does not allow you to convert a generic reference to a null reference, which has the following explanation:

Hypothetically this general reference to the intention (perhaps it is conceptually should be mandatory, rather than a concept may be empty).

But this argument is no reason, if a reference to the actual enforcement can be implicitly converted to a null reference, then a "conceptual enforces referential" should be able to achieve this conversion.

Similarly is from enforces referential null reference or converted to general reference is not allowed, which is based on the same grounds, although the reason there are some doubts.

Constructor

The proposal for a non-null reference type, there are still a problem to be solved, it is difficult to enforce this non-emptiness in the constructor. In this regard, a proposal is not to deal with this problem. Many times as we can be in the constructor for a "read-only" field assignment, we can declare this rule does not take effect in the constructor, the need to develop himself noticed.

At first glance, this proposal it would be counter-productive, but it is actually very reasonable. Developers are already in the constructor may need to pay attention to access uninitialized field would bring problems. This is a proposal does not change this phenomenon, if developers ignore this, then the constructor will generate an error, which would reduce the risk of a null reference exception occurs.

Mixed legacy code and new code

Non-null reference this proposal also need to face another problem, that is how to deal with legacy code. For example, if you have upgraded to the base class library, in which the use of this new syntax. The existing application code changes may not be possible immediately, then there must be some mechanism to turn off the use of this new syntax. This proposal provides a IgnoreNewStyleReferences property, it can refer to a new centralized external program uses the syntax by ignoring it.

More details about available null reference

In the foregoing, we can mention a null reference may be in one of two states: unknown or determined non-null (Note: You may also judged to be empty). This is further illustrated this proposal, if a reference has been determined to be empty, then after the code can not use it (assigned to another variable may be empty), developers must use a hard-coded null, which also It allows intent of the code shown even more clearly.

Other issues

This proposal there are many issues need to be addressed. For example, whether to define mandatory reference array? When using reflection of how exposure to enforce referential and non-null reference? How to turn the interaction between them and generics?
     
         
         
         
  More:      
 
- Dockerfile use to build a mirror-based CentOS 7 (Linux)
- Linux iostat command example explanation (Linux)
- Linux Getting Started tutorial: 3D effects and beautify your desktop (Linux)
- LNMP summary of the issues common 502 Bad Gateway (Server)
- OpenStack image production in the CentOS 6.2 (Linux)
- Bash How to read a file line by line (Programming)
- TCP protocol flaw incomplete records (Linux)
- Spring multi data source configuration (Programming)
- How to install the client sqlplus under linux (Database)
- Hadoop configuration ssh automation of automation (Server)
- Oracle inverted reverse function (Database)
- The method of MySQL two kinds of incomplete recovery (Database)
- Basic Operation Linux files and directories (Linux)
- Let you Fun Ubuntu desktop eleven weapon (Linux)
- How to track performance issues when using the Unity Game Development Android (Programming)
- TL-WR703N to install OpenWrt process notes (Linux)
- Build Python3.4 + PyQt5.3.2 + Eric 6.0 development platform Ubuntu 14.04 (Server)
- Linux System Getting Started Learning: The Linux ac command (Linux)
- Shilpa Nair interview experience sharing RedHat Linux package management (Linux)
- CentOS7 installation GAMIT and GMT (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.