登录 注册
当前位置:主页 > 资源下载 > 12 > c#、asp.net基础程序练习下载

c#、asp.net基础程序练习下载

  • 更新:2024-06-20 13:35:26
  • 大小:153KB
  • 推荐:★★★★★
  • 来源:网友上传分享
  • 类别:C# - 后端
  • 格式:DOCX

资源介绍

命名变量,变量计算等(WindowsFormsApplication1): using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { textBox1.Text="hello"; string teststring="hello, world!"; //定义变量 textBox1.Text = teststring; } private void textBox1_TextChanged(object sender, EventArgs e) { } private void button2_Click(object sender, EventArgs e) { int testint1 = 1000; //定义变量 int testint2 = 60; testint2 += 60; testint1 /= 2; textBox1.Text = Convert.ToString(testint1 + testint2); //变量相加 textBox2.Text = Convert.ToString(testint1 % testint2); //变量取余数 textBox3.Text = Convert.ToString( testint2); //取最终变量数 textBox4.Text = Convert.ToString(testint1); //取最终变量数 textBox5.Text = Convert.ToString(--testint1); //取自减一 textBox6.Text = Convert.ToString(++testint1); //取自加以 textBox7.Text = Convert.ToString(testint1--); //取自减一 textBox8.Text = Convert.ToString(testint1); //取自减一 textBox9.Text = "\"hello, \n world!\""; //换行符和转移符 textBox10.Text = testint1 > testint2 ? "大于" : "不大于"; // > 的选择 textBox11.Text = testint1 == testint2 ? "相等" : "不相等"; // == 的选择 textBox12.Text = testint1 != testint2 ? "不相等" : "相等"; // != 的选择 Boolean testboolean = true; label1.Text = Convert.ToString(testboolean); label2.Text = Convert.ToString(!testboolean); label3.Text = Convert.ToString(6 == 3 & 3 > 6); // 需要两个都满足是true,否则false label4.Text = Convert.ToString(6 != 3 & 3 < 6); label5.Text = Convert.ToString(6 != 3 ^ 3 > 6); // 需要两个都满足或都不满足是false,否则true textBox13.Text = Convert.ToString(10 << 3); //二进制的计算 textBox14.Text = Convert.ToString(10 >> 3); //二进制的计算 } private void textBox6_TextChanged(object sender, EventArgs e) { } private void Form1_Load(object sender, EventArgs e) { } private void textBox13_TextChanged(object sender, EventArgs e) { } private void button3_Click(object sender, EventArgs e) { int testint1 = 1; int testsum = 0; while (testint1 <= 100) { //while语句 testsum += testint1; testint1++; } label9.Text = "计算结果为:" + testsum; string teststring = textBox17.Text; switch (teststring) { //case语句 case "第一": label6.Text = "第一个条件满足"; break; case "第二": label7.Text = "第二个条件满足"; break; default: label8.Text = "其他情况"; break; } } private void textBox15_TextChanged(object sender, EventArgs e) { } private void textBox17_TextChanged(object sender, EventArgs e) { } private void button4_Click(object sender, EventArgs e) { int testint = 100; if (testint > 60) //if语句 { textBox15.Text = "大于60"; } else if (testint > 80) { textBox15.Text = "大于80"; } else if (testint > 200) { textBox15.Text = "小于200"; } textBox16.Text = "好的"; goto hello; //goto语句 hello: textBox16.Text = "hello"; } } }