. NET Study notes----2015-07-10 (Basic review and Exercise 09)

Source: Internet
Author: User

1. Please set the string array {" China ", " USA ", " Brazil ", " Australia ", " the content in Canada "} is reversed. Then output the inverted array. The Reverse () method of the array cannot be used .

        Static voidMain (string[] args) {            string[] STRs = {"China","United States","Brazil","Australia","Canada","Spain" }; //first and last swap//Exchange STRs. LENGTH/2 Times             for(inti =0; I < STRs. Length/2; i++)            {                stringtemp = Strs[strs. length-1-i]; Strs[strs. Length-1-I] =Strs[i]; Strs[i]=temp; }             for(inti =0; I < STRs. Length; i++) {Console.Write (Strs[i]+" ");        } console.readkey (); }

2. Create a person class, attribute: Name, gender, age; Method:sayhi () . Create an Employee class to inherit the person class, extend the property Salary, override Sayhi method.

Parent class:

    classPerson { Public stringName {Get; Set; }         Public intAge {Get; Set; }         Public CharGender {} Public Virtual voidSayhi () {Console.WriteLine ("I'm the sayhi of the Father's class."); }    }

Sub-class:

 class   Employee:person { 
   
    public  
    double  
     Salary {
    get  
    ;         
    set  
    ;  
    public  
    override  
    void  
     Sayhi () {Console.WriteLine ( 
     " 
     subclass Overrides parent class  
    "  
            ); }    }
   

Using the WinForm form, make a simple calculator, which defaults to "Please select". Requires a +,-,*,/ function, when the user clicks the "equals" button, if the input is not a number prompts the user:

     Public Partial classForm1:form { PublicForm1 () {InitializeComponent (); }        Private voidForm1_Load (Objectsender, EventArgs e) {Combobox1.selectedindex=0; }        Private voidbtnStart_Click (Objectsender, EventArgs e) {            Try            {                intN1 =Convert.ToInt32 (TextBox1.Text.Trim ()); intN2 =Convert.ToInt32 (TextBox2.Text.Trim ()); stringOper =comboBox1.SelectedItem.ToString (); Switch(oper) { Case "+": Label1. Text = (N1 +n2).                        ToString ();  Break;  Case "-": Label1. Text = (N1-n2).                        ToString ();  Break;  Case "x": Label1. Text = (N1 *n2).                        ToString ();  Break;  Case "/": Label1. Text = (N1/n2).                        ToString ();  Break; default: MessageBox.Show ("Please select the correct operator");  Break; }            }            Catch{MessageBox.Show ("Please enter the correct number"); }        }    }

. NET Study notes----2015-07-10 (Basic review and Exercise 09)

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.