A small knowledge in C #

Source: Internet
Author: User

This is my first blog post. I will not talk much about nonsense. Let's go straight to the topic. I am a newbie. As a newbie, I look at the variable. Tostring ()... why can it be ??? So I took some frameworks from my previous project and looked at them. The following example is provided:

Public static partial class OVerrid
{
Public static int ToInt (this object value, int def)
{
If (value = null)
{
Return def;
}
Int result;
If (! Int. TryParse (value. ToString (), out result ))
{
Return def;
}
Return result;
}

Public static int ToInt (this object value)
{
Return ToInt (value, 0 );
}
}

 

Static void Main (string [] args)
{
String aa = "";
Aa. ToInt ();

}

 

Is it naive ?? No way !! Continue Learning and exploring!

 

 

 

 

 

 

This article from the "one person's growth" blog, please be sure to keep this source http://mylinx.blog.51cto.com/4491306/1216905

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.