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)