C # programmer interview (1) answer

xiaoxiao2021-03-06  51

Prerequisites: The status bar panel SBPFILEPATH has been set to your own painting style. After the following code segment 1 is executed once: code segment 1: private void treewarchives_aftelect (Object sender, system.windows.Forms.treeViewEventArgs e) {if (e. " Node.Text = "") {try {this.richtexebox.LoadFile (Application.StartupPath e.Node.Text);! statusMessages = e.Node.Text; sbpFilePath.Text = statusMessages; // statusMessages string representing} catch {MessageBox.Show ( "loading file error, can not show!");}}} code segment 2: private void statusBar1_DrawItem (object sender, System.Windows.Forms.StatusBarDrawItemEventArgs sbdevent) {// draw panel region sbdevent.Graphics.FillRectangle (Brushes.green, sbdevent.bounds); // Draw text on the panel SBDEvent.graphics.drawstring (statusmessages, sbdevent.bound, brushes.white, sbdevent.bounds); sbdevent.graphics.dispose ();} test questions: 1. Will the code segment 2 will be executed? Answer: will. 2, code segment 2 If it is not performed, why? How to modify it? Answer: Over. Continue the next problem. 3, code segment 2 If it will be executed, will it be repeated (ie two or more times)? Answer: will. 4, code segment 2 If it is repeated, how to modify it only? Answer: 1 may be modified to code segment: private void treeviewArchives_AfterSelect (object sender, System.Windows.Forms.TreeViewEventArgs e) {if {try {this.richtexebox.LoadFile (Application.StartupPath (e.Node.Text = ""!) E.Node.Text); StatusMessages = E.Node.Text; // Note the following: Plus the mandatory method //sbpfilepath.text=statusMessages (//statusMESSAGES) indicates string statusbar1.invalidate );} Catch {messagebox.show ("Load file error, unable to display!");}}} 5, code segment 2 SBDEvent.graphics.dispose (); // This statement can be available, why? Answer: To release resources as much as possible, as long as the compilation is not wrong, it should be added. (If the site has disputes, leave a list, let him go back to test, the next day with test reports again) 6, assume that the following statement {sbpfilepath.text = statusmessages; sbpfilepath.text = statusmessages;} Questions with the above 1-3 items Please answer again.

转载请注明原文地址:https://www.9cbs.com/read-114915.html

New Post(0)