Dig a series of things that are not commonly used in C # (3) -- StackTrace, Trim

Source: Internet
Author: User

  

The time is too fast. In May March, it will be over again. Say goodbye... We will continue to look forward to the unpredictable April S. Today we will continue to explore.

We may see the most e parameter in catch. There is a StackTrace in it, and it is undeniable that this is too useful. It will call the stack

With it, we can quickly know the execution stream of the running code and quickly locate the problem.

Sometimes we encounter two problems:

①: Online bugs cannot be reproduced locally.

②: Due to too many polymorphism and design patterns, programmers are confused about the flow of online code execution.

To clarify and solve these two problems, we care about the code execution flow and the suspicious variable values in the current context when viewing the Production Log. Obtain suspicious

Variable value. We can record some variable values to log, but how can we record the call stack information of the current statement?

                 Main(              Person person =                                      Fly(             Fly(              Console.WriteLine();      }

 

This is not... The file name, method name, and number of rows have all been deprecated, which is a powerful tool for us to see the Production Log.

 

I don't know how many programmers know this, but there is an overload in it ~

 

As you can see, I can remove the specified characters before and after the string, as long as I apply for it in char [], rather than just removing spaces. Why do I mention it this time?

Use asp for several days. net, there is a join method in asp, but it is not like the String in C. the Join (",") method can remove the "," at the end, such

Array {1, 2, 3}, after join in asp, it will become "1, 2, 3,", and C # will become "1, 2, 3 ", when asp is passed in, Trim can be used to remove it in C #.

"," At the end.

              s =                r = s.Trim( [] {                 Console.Read();

  

Okay. That's all about it. There's no technical content. The point is to dig it out. It may be useful to you ~

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.