C#代码计算器
来源:互联网 发布:搭建高并发java框架 编辑:程序博客网 时间:2024/06/06 00:26
using System;using System.IO;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace MyCodeCal{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } static int codeLine = 0; static int commentLine = 0; static int blankLine = 0; static int all = 0; private void btnstart_Click(object sender, EventArgs e) { lblshow.Text = ""; btnstart.Visible = false; btncontinue.Visible = true; txtBox.Visible = true; } private void btncontinue_Click(object sender, EventArgs e) { lblshow.Text = "正在统计..."; string dir = txtBox.Text; directoryCountLine(dir); btnresult.Visible = true; } static void directoryCountLine(string directory) { foreach (string file in Directory.GetFiles(directory, "*.cs")) { countLine(file); } } static void countLine(string file) { FileStream stream = new FileStream(file, FileMode.Open); StreamReader reader = new StreamReader(stream); string line = reader.ReadLine(); while (line != null) { if (line.Trim() != "" && !(line.Trim().StartsWith(@"//"))) { codeLine++; } else if (line.Trim().StartsWith(@"//")) { blankLine++; } else { commentLine++; } all = codeLine + commentLine + blankLine; line = reader.ReadLine(); } reader.Close(); } private void Form1_Load(object sender, EventArgs e) { lblshow.Text = "功能介绍!\n" + "1.此程序可以统计出所在文件夹C#程序代码总行数\n" + "2.代码行数\n" + "3.注释行数\n" + "4.空白行数\n"; } private void btnresult_Click(object sender, EventArgs e) { btncontinue.Visible = false; txtBox.Visible = false; lblshow.Text = "C#代码行数为:\n"+codeLine+ "\n注释行:\n" + commentLine + "\n空白行:\n" + blankLine + "\n总的代码行数为:\n" + all; } }}
开始界面:
0 0
- C#计算器代码
- C#实现计算器代码
- C#代码计算器
- C#计算器简单代码示例
- C#计算器混合运算代码
- Visual C# .Net 计算器部分代码
- C# 计算器代码(面向对象)
- c# 开发计算器视频及代码下载
- C# 计算器
- C# 计算器
- c# 计算器
- C# 计算器
- c#计算器
- C#计算器
- C# 计算器
- C#计算器
- C# 计算器
- c# 计算器
- 【整理】国内cdn常用js公共库地址
- 正点办公让中小企业管理更简单有效
- 让指定的layout不被弹出输入法遮挡
- Python进程间通信之匿名管道
- mysql数据库优化
- C#代码计算器
- eclipse安装反编译工具jad打开.class文件报错
- angular小结,周末补上!
- plsql连接局域网 Oracle 问题
- Python标准库re正则表达式
- 分享PDF转成PPT好用的方法
- 黑马程序员-Java集合框架整体观
- 注解 对象中字段是否允许修改
- qt QLabel 显示网络图片