-
C# 确定字符串末尾是否匹配指定子串
C# 确定字符串末尾是否匹配指定子串,本字符串查询实例具体到只匹配字符串开头和结尾是否有指定的字符串,下面是具体的查询代码编写方法:
private void button1_Click(object sender, EventArgs e)
{//确定字符串开头是否匹配指定子串
string MyFullInfo = "中华人民共和国";
string MyPartInfo="中华";
if(MyFullInfo.StartsWith(MyPartInfo))
MessageBox.Show(MyFullInfo + " 的开头是 " + MyPartInfo, "信息提示", MessageBoxButtons.OK);
else
MessageBox.Show(MyFullInfo + " 的开头不是 " + MyPartInfo, "信息提示", MessageBoxButtons.OK);
}
private void button2_Click(object sender, EventArgs e)
{//确定字符串末尾是否匹配指定子串
string MyFullInfo = "中华人民共和国";
string MyPartInfo = "共和国";
if (MyFullInfo.EndsWith(MyPartInfo))
MessageBox.Show(MyFullInfo + " 的末尾是 " + MyPartInfo, "信息提示", MessageBoxButtons.OK);
else
MessageBox.Show(MyFullInfo + " 的末尾不是 " + MyPartInfo, "信息提示", MessageBoxButtons.OK);
}
- 2022-02-09 23:32:04下载
- 积分:1
-
C# winform邮件发送 可抄送、密送、发附件
C# 可抄送、密送、发附件的Winform发邮件程序,邮件主是信息的填写部分要注意格式不能错,抄送和密送时多个收件人以分号隔开,可连续发送多个附件,多个附件以分号隔开。发送邮件采用了发送邮件函数的方式,方便以模块化调用 ,发邮件还可异步发送,SMTP 服务器要求安全连接需要设置smtp.EnableSsl = Ssl属性。
请注意:发送邮件前,请先配置然后再发邮件(注:以上参数为格式示例,需自行更改为实际真实有效的信息)。
发邮件的整体用户界面如测试图所示。
- 2023-08-13 11:10:02下载
- 积分:1
-
C#多个读写文本文件的方法含示例
C#多个读写文本文件的方法含示例,比如"以文本行为单位写文本文件、以文本行为单位读文本文件、一次性向文本文件写入数据、一次性从文本文件读取数据、一次性向文本文件追加数据。
- 2022-05-12 17:08:46下载
- 积分:1
-
C语言实现socks5协议
C语言实现socks5协议,亲测有效。可以简单测试客户端与服务器之间的通信,支持在linux机器上运行,提供源码。
- 2022-07-19 01:01:48下载
- 积分:1
-
C# 按照扩展名分组文件
C# 按照扩展名分组文件,按照文件类型的不同,对文件进行归类显示,分类清淅便于查看,主要是使用MyFile中的对象和方法实现,核心的功能代码如下:
private void ShowGroupFile(IEnumerable> MyQueryGroup)
{
this.listBox1.Items.Clear();
foreach (var MyFileGroup in MyQueryGroup)
{
this.listBox1.Items.Add("包含" + MyFileGroup.Key + "扩展名的文件如下:");
foreach (var MyFileInfo in MyFileGroup)
{
this.listBox1.Items.Add(MyFileInfo.Name);
}
this.listBox1.Items.Add("");
}
}
static IEnumerable GetFiles(string MyDir)
{
if (!System.IO.Directory.Exists(MyDir))
throw new System.IO.DirectoryNotFoundException();
string[] MyFileNames = null;
List MyFiles = new List();
//查找指定目录下的所有子目录中的所有文件
//MyFileNames = System.IO.Directory.GetFiles(MyDir, "*.*", System.IO.SearchOption.AllDirectories);
MyFileNames = System.IO.Directory.GetFiles(MyDir);
foreach (string MyName in MyFileNames)
{
MyFiles.Add(new System.IO.FileInfo(MyName));
}
return MyFiles;
}
- 2022-12-28 08:15:04下载
- 积分:1
-
C# 保存对数据库记录的插入、删除及修改操作结果
C# 保存对数据库记录的插入、删除及修改操作结果,设置控件数据源,对操作的结果以MessageBox.Show在消息框中显示提示信息,执行过程中验证Shippers数据表、验证Phone字段、验证CompanyName字段
- 2022-04-08 04:57:49下载
- 积分:1
-
C# 写入并读取内存流
C# 写入并读取内存流,演示一些基本的内存流操作方法,编写以下代码可实现这些功能:
byte[] BContent = Encoding.Default.GetBytes(textBox1.Text);
MemoryStream MStream = new MemoryStream(100);
MStream.Write(BContent, 0, BContent.Length);
richTextBox1.Text = "分配给该流的字节数:" + MStream.Capacity.ToString() + "
流长度:"
+ MStream.Length.ToString() + "
流的当前位置:" + MStream.Position.ToString();
MStream.Seek(0, SeekOrigin.Begin);
byte[] byteArray = new byte[MStream.Length];
int count = MStream.Read(byteArray,0,(int)MStream.Length-1);
while (count < MStream.Length)
{
byteArray[count++] = Convert.ToByte(MStream.ReadByte());
}
char[] charArray = new char[Encoding.Default.GetCharCount(byteArray, 0, count)];
Encoding.Default.GetChars(byteArray, 0, count, charArray, 0);
for (int i = 0; i < charArray.Length; i++)
{
richTextBox2.Text += charArray[i].ToString();
}
- 2022-03-11 09:55:00下载
- 积分:1
-
C# 获取Access数据库的数据表名称
C# 获取Access数据库的数据表名称,private void button1_Click(object sender, EventArgs e)
{//获取Access数据库的数据表名称
string MyAccessDBFile = @"F:Northwind.mdb";
string MyConnectString ="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" +MyAccessDBFile;
var MyConnection = new System.Data.OleDb.OleDbConnection(MyConnectString);
MyConnection.Open();
var MyTables = MyConnection.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
string MyInfo = MyAccessDBFile + "数据库的数据表包括:";
foreach (DataRow MyRow in MyTables.Rows)
{
string MyTable = MyRow["TABLE_NAME"].ToString();
MyInfo += MyTable + "、";
}
MessageBox.Show(MyInfo, "信息提示", MessageBoxButtons.OK);
}
- 2023-01-05 19:40:03下载
- 积分:1
-
程序守护(进程守护)-源代码C#
程序守护(进程守护)-源代码C#
/*
* 由SharpDevelop创建。
* 用户: zhang
* 日期: 2017/3/18
* 时间: 21:50
* 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
*/
using System;
using System.Diagnostics;
using System.Drawing;
using System.Threading;
using System.Windows.Forms;
namespace CPinfoSafe
{
public sealed class NotificationIcon
{
private NotifyIcon notifyIcon;
private ContextMenu notificationMenu;
DialogResult dr;
#region Initialize icon and menu
public NotificationIcon()
{
notifyIcon = new NotifyIcon();
notificationMenu = new ContextMenu(InitializeMenu());
notifyIcon.DoubleClick += IconDoubleClick;
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(NotificationIcon));
notifyIcon.Icon = (Icon)resources.Get
- 2022-11-01 19:35:03下载
- 积分:1
-
C# 序列中所有元素是否都满足指定条件
C# 序列中所有元素是否都满足指定条件,使用List序列对象创建List人员列表,判断是否所有人员的年龄都大于30岁,dgpwC#中序列的用法:
bool result = People.All(p => p.Old > 30);显示查询结果:
label1.Text = "数据源:{1,"王*军",28},{2,"赵*东",31},{3,"王*科",33}";//数据源
label2.Text = "查询表达式:All(p => p.Old > 30)";//查询表达式/操作
label3.Text = "查询结果:" + result.ToString();//查询结果
更详细代码请下载源码。
- 2023-08-15 15:50:03下载
- 积分:1