ImageVerifierCode 换一换
格式:DOCX , 页数:20 ,大小:91.95KB ,
资源ID:4712228      下载积分:12 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/4712228.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(C#复习提纲.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

C#复习提纲.docx

1、C#复习提纲1、从键盘读入一个字符串,赋给变量i int x = Convert.ToInt32(Console.ReadLine();2、 /将字符串转换为整型数据 int x = Convert.ToInt32(i);3、/foreach p34 foreach (int index in list.Keys) Console.WriteLine(index + t + listindex);4、数组 p471) 定义:int, b = new int3, 5;2) 长度: for (int i = 0; i b.GetLength(0); i+) 3) 二维数组中,没有的元素,不显示,可

2、以空着 【b0 = new string2 b11, b12 ;】【b1 = new string3 b21, b22, b23 ;】 【b2 = new string5 a, e, i, o, u ;】4) 数组调整长度:【 String myArr = fox, lazy, dog ;【 Array.Resize(ref myArr, myArr.Length + 2);5) 数组的排序函数:【Array.Sort(books);/升序函数【Array.Reverse(books);/降序函数【books.Contains(C#) ;/包含函数【Array.IndexOf(books, C

3、#);/元素在数组中的位置6)将数组中的元素转换为字符static string GetStrings(int a) string s = new stringa.Length; for (int i = 0; i a.Length; i+) si = ai.ToString(); return s; 7)数组函数:int a = 10, 20, 4, 8 ;【 a.Average()【 a.Sum()【 a.Max()【 a.Min()5、字符 p42【 string.Join(, colorNames);/将各个字符用“,”连接【 string str = string.Format( 6

4、、泛型 p54-55public static void Swap(ref T item1, ref T item2) T temp = item1; item1 = item2; item2 = temp; 7、列表 p57 【List list = new List(); 8、时间 p61【DateTime now = DateTime.Now;【string str = string.Format( 0:现在是yyyy年M月d日,H点m分,dddd, now);9、数学函数 Math p62SuperCombine:using System;using System.Collection

5、s.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.IO;using System.Data.SqlClient;namespace WindowsFormsApplication1 public partial class SuperCombine : Form public SuperCombine() InitializeComponen

6、t(); /目录的创建事件 private void btnCreateDir_Click(object sender, EventArgs e) try if (!txtPath.Text.Equals() string str = txtPath.Text.Trim(); Directory.CreateDirectory(str); MessageBox.Show(成功创建目录); else MessageBox.Show(请重新输入要建的目录!); catch (Exception ex) throw(ex); /文件创建的事件 private void btnCreateFile_C

7、lick(object sender, EventArgs e) try if (!txtPath.Text.Equals() string str = txtPath.Text.Trim(); File.Create(str); MessageBox.Show(成功创建文件!); else MessageBox.Show(请重新输入要创建文件!); catch (Exception ex) throw (ex); /打开并显示某个目录下的所有文件的事件 private void btnOpen_Click(object sender, EventArgs e) if (folderBrows

8、erDialog1.ShowDialog() = DialogResult.OK) textBox1.Text = folderBrowserDialog1.SelectedPath; string path = textBox1.Text.Trim(); if (!Directory.Exists(path) MessageBox.Show(文件夹不存在!); return; string files = Directory.GetFiles(path); for (int i = 0; i files.Length; i+) string tmp = Path.GetFileName(fi

9、lesi); listBox1.Items.Add(tmp); /打开所选的文件里的内容 private void listBox1_MouseDoubleClick(object sender, MouseEventArgs e) string file = listBox1.SelectedItem.ToString(); file = textBox1.Text.Trim() + + file; string ext = Path.GetExtension(file); if (ext.ToLower() = .txt) richTextBox1.Text = File.ReadAllT

10、ext(file); else MessageBox.Show(请选择txt文件); /combox控件的操作 private void btnShow_Click(object sender, EventArgs e) try /数据库连接部分 string con = server=localhost;uid=sa;pwd=as;database=db_course; SqlConnection sqlcon = new SqlConnection(con); /提取数据库中的内容放入适配器,再放入datatable中 string SQL = select sno from studen

11、t; SqlDataAdapter da = new SqlDataAdapter(SQL, con); DataTable dt = new DataTable(); /适配器里的数据填充入dt中 da.Fill(dt); comboBox1.Items.Clear(); for (int i = 0; i 0) MessageBox.Show(操作成功!?, 提示); fileOpration_Load(null,null); catch (Exception ex) throw (ex); private void btnDelete_Click(object sender, Event

12、Args e) string strSql = ; strSql = delete from student where sno= + txtSNo.Text + and sname= + txtSName.Text + ; try string con = server=localhost;uid=sa;pwd=as;database=db_course; SqlConnection sqlcon = new SqlConnection(con); SqlCommand cmd = new SqlCommand(strSql, sqlcon); sqlcon.Open(); cmd.Exec

13、uteNonQuery(); sqlcon.Close(); MessageBox.Show(删除成功!, 提 示); fileOpration_Load(null, null); catch (Exception ex) throw (ex); /string strSql = update(Sno,sname,sage) values( + txtSNo.Text + , + txtSName.Text + , + txtSAge + , + ); 文件的操作 private void button2_Click(object sender, EventArgs e) string pat

14、h1 = e:temp; string files = Directory.GetFiles(path1); for (int i = 0; i files.Length; i+) string dirName = Path.GetDirectoryName(filesi); string extName = Path.GetExtension(filesi); string fileNameNoExt = Path.GetFileNameWithoutExtension(filesi); fileNameNoExt = (Convert.ToInt32(fileNameNoExt).ToSt

15、ring();/去掉数字前面的“0 【fileNameNoExt = fileNameNoExt.PadLeft(3,0);】 string fileName = dirName + + fileNameNoExt + extName; File.Move(filesi, fileName); /能够使文件显示 /for/流水线插入学号 string con = server=localhost;uid=sa;pwd=as;database=Renee; SqlConnection sqlcon = new SqlConnection(con); /执行查询到最大的学号 string strS

16、ql1 = select max(sno) from testSno; SqlCommand com1 = new SqlCommand(strSql1,sqlcon); sqlcon.Open(); /执行查询,并返回查询所返回的结果集中的第一行的第一列,忽略其他行和列 string value = com1.ExecuteScalar().ToString(); sqlcon.Close(); /截取后四位 string strLF=value.Substring(4,4); int numLF = Convert.ToInt32(strLF);/转换为int numLF+; /拼接字符串

17、 string newLF = Convert.ToString(numLF).PadLeft(4, 0); /解决convert.ToInt32,填充0 string Last = value.Substring(0, 4) + newLF; /插入数据库 string strSql2 = insert into testSno(sno) values( + Last + ) ; sqlcon.Open(); SqlCommand com2 = new SqlCommand(strSql2, sqlcon); com2.ExecuteNonQuery(); sqlcon.Close(); /

18、over MessageBox.Show(Last);/实现学号位数的扩充,如从0-999到0-9999的扩充 string con = server=localhost;uid=sa;pwd=as;database=Renee; SqlConnection sqlcon = new SqlConnection(con); /执行查询到最大的学号 string strSql1 = select * from testSno; SqlCommand com1 = new SqlCommand(strSql1, sqlcon); sqlcon.Open(); string value = com1

19、.ExecuteScalar().ToString(); sqlcon.Close(); SqlDataAdapter sda = new SqlDataAdapter(strSql1, sqlcon); DataTable dt = new DataTable(); sda.Fill(dt); for (int i = 0; i dt.Rows.Count; i+) int id =Convert.ToInt32( dt.Rowsiid); string strRg = dt.Rowsisno.ToString().Substring(0, 4); string strLF = dt.Row

20、sisno.ToString().Substring(4, 4); string temp = strRg + 0 + strLF; /插入数据库 string strSql2 = update testSno set sno=+temp+ where id=+id+; sqlcon.Open(); SqlCommand com2 = new SqlCommand(strSql2, sqlcon); com2.ExecuteNonQuery(); sqlcon.Close(); 删除当前行private void 删?除yToolStripMenuItem_Click(object sende

21、r, EventArgs e) try int row = dataGridView1.CurrentRow.Index; if (row 0) return; string sno = dataGridView1sno, row.Value.ToString(); DialogResult result = MessageBox.Show(确_实害_删?除y学号?为a + sno.Trim() + 的?记?录?吗e??,询问信?息,MessageBoxButtons.YesNo,MessageBoxIcon.Question); if (result = DialogResult.No) r

22、eturn; string sql = delete from student where sno=+ sno +; DBTOOL.SqlCmdOperation(sql); MessageBox.Show(删?除y成功|!?); catch (Exception ex) MessageBox.Show(ex.Message); 删除选中行private void toolStripMenuItem2_Click(object sender, EventArgs e) /删?除y选?中D行D try if (dataGridView1.SelectedRows.Count = 0) MessageBox.Show(您还1没?有瓺选?中D行D!?); return; DialogResult result = MessageBox.Show(确_实害_删?除y吗e??, 询问信?息, Message

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1