1。控件遍历并判断
foreach (Control c in this.Controls)
{
if (c is TextBox)
{
c.Text = "";
}
}2,局部区域截图
void button1_Click(object sender, EventArg e)
{
Rectangle roi = new Rectangle(0, 0, 300, 200);
using( Bitmap bmp = new Bitmap(roi.Width,roi.Height))
using(Graphics g = Graphics.FromImage(bmp))
{
g.CopyFromScreen( this.PointToScreen( roi.Location), Point.Empty, roi.Size );
bmp.Save(@"c:\temp\dump.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
}
}
3.checked和unchecked
用于检查整数运算时候,是否出现有益出
3.注册DLL
简单点说吧就是调用 DLL中的DllRegisterServer函数来注册,调用DllUnregisterServer函数来取消注册
[DllImport("你要登记的Dll")]
static extern int DllRegisterServer();
[DllImport("你要登记的Dll")]
static extern int DllUnregisterServer();
4.如何判断网络是否断开
private void GetNetworkInterface()
{
if (NetworkInterface.GetIsNetworkAvailable ())
{
MessageBox.Show("网络连接可用!");
}
else
{
MessageBox.Show("网络连接已断开!");
}
}