"C #" Everything Starts hard (b) < Machine room reconstruction >

Source: Internet
Author: User

Preface

The machine room will be finished, the reason why still use this topic, is because I want to tell myself. No matter how unknown things face. Don't be afraid, just do it. In so many days of machine room reconstruction, found a lot of problems, but also overcome a lot of problems, today, I solve the problem to share to everyone.

Branch Display in top- up

In the recharge and return card function window, we will display some information branches to Lablebox, then how does this branch do?

Lbldetail.text = "Prepaid card number:" + txtCardNo.Text.Trim () + system.environment.newline+ "Recharge Amount:" +txtaddmoney.text.trim () + System . Environment.NewLine + "Remaining Amount:     " + list[0]. Cash + System.Environment.NewLine + "top-up Teacher:" + Entity.Model.user + System.Environment.NewLine + System.Environment.NewLin E + "Recharge time:" + DateTime.Now;
The above code. Detailed operations such as the following:

1. Set the TextBox's property multiline to true first.

2, textbox.text= "Fistline" +system.environment.newline+ "Secondline" +system.environment.newline+.

。。。

+ "Nth Line" +system.environment.newline

It's that simple.

Show Transformations

In C #, there are basically three ways to convert a string or floating-point number to an integer:

1. Use forced type conversion: (int) floating-point number. Truncated such as int a= (int) 2.8; Result is 2)

2. Use Convert.ToInt32 (String).

(rounding, such as int b=convert.toint32 (2.8); The value of B is 3)

3, use Int. Parse (String). (Assume that you cannot convert to an integer.) The exception is reported, such as int c=int. Parse ("2.8"); The parameter must be an integer string)

4, Int. TryParse (string,out int). (int.) TryParse ("2.8", out c); Cannot be converted successfully, the result is 0,int. TryParse ("2", out c); Conversion succeeded, result is 2)

So what happens when the information you want to convert is a character instead of a number? See Example:

1, int a = (int) ' A '; The result is 97. Note that it is a character, not a string, which is assumed to be a string. Compilation cannot be passed).

2, int b = Convert.ToInt32 ("a"); The report is abnormal.

3, int c=int.  Parse ("a"); The report is abnormal.

4, int d = -1;int. TryParse ("A", out d); The result is 0.

Exit Program

When exiting a program, assume that you are using close directly, and sometimes you can find it in Task Manager.

So. Do you have any knowledge about quitting?

1, this.   Close (); Just close the current window. If it weren't for the main window. is unable to exit the program, and if there are managed threads (not the main thread), can not cleanly exit;
2, Application.exit (); Forces all messages to abort, exiting all windows, but if there are managed threads (not the main thread). Nor can it be cleanly exited;
3, Application.exitthread (); Force aborts all messages on the calling thread, with the same problem that other threads are not able to exit correctly.
4, System.Environment.Exit (0); This is the most thorough exit method, no matter what threads are forced to quit, the program ends very clean.

get the current machine name

such as code: Text1.Text = environment.username;

events for individual controls in vs

Refactoring I made a particularly interesting mistake, is that before the first version of the VB computer room. The ability to double-click the window and find all the properties of the control below the taskbar, but this time the VS cannot be found, until. , I saw in Baidu's time three words: small lightning! Right. That's right. Is it, suppose you want to compile individual events for a control. Just click this window and there is a small lightning bolt next to its properties, and that's all it's about.

Inheritance Selector Error


The problem is generated because the executable file is not available, and the workaround is to build and run the program again, generating a running file for the window.

Summary

In the process of machine room reconstruction. The summary is not interrupted. It examines our knowledge. Exercise our ability to record our growth.


C # is difficult to start with (b) < machine room reconstruction >

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.