Old Chen ASP. NET Encapsulation

Source: Internet
Author: User

First page

Using system;using system.collections.generic;using system.componentmodel;using system.data;using System.Drawing; Using system.linq;using system.text;using System.io;public partial class _default:system.web.ui.page{protected Voi              d Page_Load (object sender, EventArgs e) {} protected void Button1_Click (object sender, EventArgs e) {        StreamWriter n1 = File.appendtext ("C:\\n1.txt"); N1.        WriteLine (TextBox1.Text); N1.        Close ();        StreamWriter N2 = File.appendtext ("C:\\n2.txt"); N2.        WriteLine (TextBox2.Text); N2.        Close ();        StreamWriter n3 = File.appendtext ("C:\\n3.txt"); N3.        WriteLine (TextBox3.Text); N3.        Close ();        LISTBOX1.ITEMS.ADD (TextBox1.Text + textbox2.text + textbox3.text + "\ n");        TextBox1.Text = "";        TextBox2.Text = "";    TextBox3.Text = "";    } protected void Button2_Click (object sender, EventArgs e) {//jump page Response.Redirect ("default2.aspx"); }}

Second page

Using system;using system.collections.generic;using system.linq;using system.web;using System.Web.UI;using System.web.ui.webcontrols;using System.io;public partial class default2:system.web.ui.page{protected void Page_Load (    Object sender, EventArgs e) {}//starts public static int Count = 0;    public static int right = 0;    The number of totals and the correct number of int m = 0;        protected void Button1_Click (object sender, EventArgs e) {//Quiz string[] n1 = new string[100];        N1 = File.ReadAllLines ("C:\\n1.txt");        TextBox1.Text = N1[m];        String[] N2 = new string[100];        N2 = File.ReadAllLines ("C:\\n2.txt");        TextBox2.Text = N2[m];        string[] n3 = new STRING[100];        N3 = File.ReadAllLines ("C:\\n3.txt");        TextBox3.Text = N3[m];    m++;        } protected void Button2_Click (object sender, EventArgs e) {textbox4.enabled = false; Response.Write ("The operation is over!"        "); Textbox5.text = Default2.Count.ToString ();//Total number of topics TextBox6.Text = Default2.right.ToString (); Textbox7.text = ((Default2.right/(double) (default2.count)) * 100). ToString () + "%";//correct rate} protected void Button4_Click (object sender, EventArgs e) {int a = Int.        Parse (TextBox1.Text); int b = Int.        Parse (TextBox3.Text);        Char C = Convert.tochar (TextBox2.Text);        Class1 con = new Class1 ();        Con.chu (A, B, c); if (con.answer = = Int. Parse (Textbox4.text)) {Response.Write ("answer right!") Next question, press the Start button!            ");            right++;        count++; } else {Response.Write ("Answer Error! Next question, press the Start button!            ");        count++; }    }}

. NET Encapsulation

Using system;using system.collections.generic;using system.linq;using system.web;///<summary>///Class1 Summary description/ </summary>public class class1{public    Class1 ()    {        //        //todo: Add constructor logic here        //    }        public int sum;        public int answer        {            get            {                return sum;            }        }        public int chu (int n1, int n2, char Fuhao)        {            if (Fuhao = = ' + ')            {                return sum = n1 + n2;            }            else if (Fuhao = = '-')            {                return sum = n1-n2;            }            else if (Fuhao = = ' * ')            {                return sum= n1 * n2;            }            return sum;        }}

After running

Old Chen ASP. NET Encapsulation

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.