C # tips for printing logs

Source: Internet
Author: User

First of all, congratulations on our upcoming game "Dragon Ring"! http://www.9game.cn/longjie/

Steal a half-free, share a little thing. is the function that prints the log. In the development of output log is necessary, in C # in the output of a number of different types of parameters, the need for connectors to accumulate output, it is inconvenient. One simple way is to encapsulate a printed function yourself,

Let it support indeterminate parameters and different types of output. This will not strongly use the string for splicing output. Maybe you don't understand the need, okay, nonsense say, on the code.

 Public Static voidLog (paramssystem.object[] message) {        stringstr =""; if(Message = =NULL|| Message. Length = =0) {str="NULL"; }        Else        {             for(inti =0; I < message. Length; i++) {str+=Message[i];    }} Debug.Log (str); }

OK, now look at the use of this function: If this class is called unitl, it needs to be printed directly Util.Log ("Hello World");

Seemingly not much difference, but can also play: Util.Log (1,4,0.5,-1); , Util.Log ("test", true,56);

OK, little tricks, nothing big on the technology. The params is used to receive indeterminate parameters, and object receives any type, so a simple encapsulated output function is done

C # tips for printing logs

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.