C # output format Control

Source: Internet
Author: User

Take this project-UML diagram. After learning it, I don't feel any gains. I don't know how to figure it out. I always think that painting is not good, but it cannot be wrong. It can only be regarded as low-level. For a UML diagram, there is no right or wrong. There is only a difference between the advanced and the low level.

I will not talk about UML first. There will certainly be many opportunities to use it in the future. It is not that demanding. Otherwise, GG will be over in UML.

Writing documents is always boring. As early as the theoretical study, we know that the UML diagram has been completed before development. If the system is complete, complete the document. This situation only appears in the student age. Besides, the person who abandoned the system for a long time writes a document in the return header. Then the system is almost re-built. When it was boring, I started learning C. Learning may not be so boring.

This is the first time we fully learn from object-oriented languages. Speaking of this, our major is one year ahead of others in terms of object-oriented programming. As for object-oriented, I always think this is a very esoteric term. It will only change as long as you use it. After learning this for a long time, I finally came to face these black boxes. After all, these are classic ..

When studying Chu Guangming's C # concise tutorial, the previous videos were all delivered by XXX University professor XXX. I have been studying for more than 10 years. This is still the form of looking back at a video. Chu Guangming, an IT worker, plays a few sets of videos every week for online users to learn. In this way, this is not a video of the Wine God. The style of the lecture. Different from teachers. No matter what the video says. Just listen to this speech as a commentator. This style of "commentary" has already hooked up a lot of dotar.

I have been watching it for a long time, and it is useless. Now let's take a look at the output format in C.

In the video, there is an example. The output format used in class inheritance is different from that in C ++. So I sorted out the output form in C # and summarized it:

Using System; using System. collections. generic; using System. linq; using System. text; using System. threading. tasks; namespace ConsoleApplication6 {class Program {static void Main (string [] args) {// Console. writeLine ("output format expression", "Parameter List"); Console. writeLine ("This is a test"); // output directly -- output the first parameter. The value occupies the width of 8 characters and is left-aligned and right-aligned. writeLine ("{} spent X yuan", "name"); // left alignment Console. writeLine ("{0,-8} spent X yuan", "name"); // right-aligned // use the parameter Console in the output format expression. writeLine ("{0} spent {1} RMB", "name", 12); // specifies the output format Console in the parameter. writeLine ("{0} spent {1: C}", "name", 12); // generate a Console containing embedded commas. write ("{0: N}", 3100000); Console. writeLine ("{0: D5}", 26); Console. writeLine (); Console. writeLine (); // formatted the output DateTime dt = DateTime. now; Console. writeLine ("Short Date Format: {0: d}", dt); Console. writeLine ("long Date Format: {0: D}", dt); Console. writeLine ("full date/time format (Short Time): {0: f}", dt); Console. writeLine ("full date/time format (Long Time): {0: F}", dt); Console. writeLine ("regular date/time format (Short Time): {0: g}", dt); Console. writeLine ("regular date/time format (Long Time): {0: G}", dt );}}}

The output format of C # is controlled. The result is as follows:


C # Is a new language, but it is similar to C ++. The difference is not too big. You only need to know the differences and make a slight modification. There is no need to learn from the beginning.



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.