Reduces the loss caused by NullReferenceException

Source: Internet
Author: User

Reduces the loss caused by NullReferenceException

I wrote a blog by ILoveSleep a few days ago. "I criticized many bloggers, but I don't think I should say something ugly to a blog. After all, ILoveSleep just shared his thoughts, if you have any questions, let's say that he is also very modest in his reply to everyone. He must be a person who can accept others' opinions. Today, I also want to say that NullReferenceException can be sprayed on everyone. I am not afraid of this person.

I don't have ILoveSleep so much patience to explain to you. At the same time, the Code is very simple, so I directly paste the code.

Class

            PreventNull<T> : Lazy<T>                                          PreventNull() :                                                   PreventNull( isThreadSafe) :                                                    PreventNull(Func<T> valueFactory) :            PreventNull(LazyThreadSafetyMode mode) :            PreventNull(Func<T> valueFactory,  isThreadSafe) :                                                             PreventNull(Func<T> valueFactory, LazyThreadSafetyMode mode) :                                                                 T(PreventNull<T>                             PreventNull<T>                PreventNull<T>( Func<T>(() => {                                                (.Value ==                        (NullErrorLog !=                          NullErrorLog(                                                                                   Action<PreventNull<T>> NullErrorLog { ;                                          Func<T> NullDefaltValue { ;   }

 

  Main(            Person p1 =  PreventNull<Person>( Func<Person>(() => {   Person() { Name = =  PreventNull<Person>( Func<Person>(() => {              Person p4 = (PreventNull<Person>) Person() { Name = =  PreventNull<Person>( Func<Person>(() => {  = (PreventNull<Person>               PreventNull<Person>.NullErrorLog =  Action<PreventNull<Person>>((p) => { Console.WriteLine(<Person>.NullDefaltValue =  Func<Person>(() => {   Person() { Name =   Name { ;   

 

 

 

 

 

 

Related Article

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.