TimeSpan span = dateTime1 - dateTime2;
System.Guid pGuid = new Guid(guid);
System.Type ObjectCustorm = Type.GetTypeFromCLSID(pGuid);
Object obj = Activator.CreateInstance(ObjectCustorm);
picLogo.Controls.Add(lblStatus);
lblStatus.BackColor = Color.Transparent;
Help.ShowHelp(this,@"c:/windows/help/mspaint.chm");
Help.ShowHelp(this,@"c:/windows/help/mspaint.chm","paint_lines.htm");
Help.ShowHelpIndex(this,@"c:/windows/help/mspaint.chm","paint_lines.htm");
Help.ShowPopup(this,"这里是帮助信息",new Point(100,100));
///
/// 用于在不同的appdomain之间传递参数
///
public class AppDomainInfo:MarshalByRefObject
{
public int UserID;
}
AppDomainSetup setup = new AppDomainSetup();
setup.ApplicationName = "测试程序";
AppDomain appDomain = AppDomain.CreateDomain("TestDomain", null, setup);
AppDomainInfo domainInfo = new AppDomainInfo();
domainInfo.UserID = Winsharp.BaseClass.AppConfigInfo.UserID;
appDomain.SetData("domainInfo", domainInfo);
object obj = appDomain.CreateInstanceFromAndUnwrap(str, "TestDomain.Test");
(obj as Form).Show();
Microsoft.Win32.RegistryKey cmicRegKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software");
cmicRegKey = cmicRegKey.OpenSubKey("Microsoft");
cmicRegKey = cmicRegKey.OpenSubKey("MS Setup (ACME)");
cmicRegKey = cmicRegKey.OpenSubKey("User Info");
object cmicCompany = cmicRegKey.GetValue("DefCompany");
object cmicUser = cmicRegKey.GetValue("DefName");
private void Form1_Deactivate(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
this.Visible = false;
}
const int WM_SYSCOMMAND = 0x112;
const int SC_CLOSE = 0xF060;
const int SC_MINIMIZE = 0xF020;
const int SC_MAXIMIZE = 0xF030;
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_SYSCOMMAND)
{
if (m.WParam.ToInt32() == SC_MINIMIZE)
{
this.Visible = false;
return;
}
}
base.WndProc(ref m);
}
string s = "Hello";
byte[] bytes = Convert.FromBase64String(s);
Convert.FromBase64String("Hell"); // Normal.
Convert.FromBase64String("Hell "); // Normal.(忽略空格)
Convert.FromBase64String("Hello!"); // throw FormatException.
Convert.FromBase64String("Hello Net"); // Normal.(忽略空格)
System.Threading.Mutex appSingleton = new System.Threading.Mutex(false, "MyProgInstance_PPP");
if (appSingleton.WaitOne(0, false))
{
Application.Run(new FormMain());
}
else
{
MessageBox.Show("程序已经运行");
}
int n = Convert.ToInt32('a');
char c = Convert.ToChar(99);
string str1 = String.Format("{0:N1}", 56789); //result: 56,789.0
string str2 = String.Format("{0:N2}", 56789); //result: 56,789.00
string str3 = String.Format("{0:N3}", 56789); //result: 56,789.000
string str8 = String.Format("{0:F1}", 56789); //result: 56789.0
string str9 = String.Format("{0:F2}", 56789); //result: 56789.00
string str11 = (56789 / 100.0).ToString("#.##"); //result: 567.89
string str12 = (56789 / 100).ToString("#.##"); //result: 567
字符 | 说明 | 示例 | 输出 |
---|---|---|---|
C 或 c | 货币 | Console.Write("{0:C}", 2.5); Console.Write("{0:C}", -2.5); | $2.50 ($2.50) |
D 或 d | 十进制数 | Console.Write("{0:D5}", 25); | 00025 |
E 或 e | 科学型 | Console.Write("{0:E}", 250000); | 2.500000E+005 |
F 或 f | 固定点 | Console.Write("{0:F2}", 25); Console.Write("{0:F0}", 25); | 25.00 25 |
G 或 g | 常规 | Console.Write("{0:G}", 2.5); | 2.5 |
N 或 n | 数字 | Console.Write("{0:N}", 2500000); | 2,500,000.00 |
X 或 x | 十六进制 | Console.Write("{0:X}", 250); Console.Write("{0:X}", 0xffff); |
string str1 = String.Format("{0:N1}", 56789); //result: 56,789.0
string str2 = String.Format("{0:N2}", 56789); //result: 56,789.00
string str3 = String.Format("{0:N3}", 56789); //result: 56,789.000
string str8 = String.Format("{0:F1}", 56789); //result: 56789.0
string str9 = String.Format("{0:F2}", 56789); //result: 56789.00
string str11 = (56789 / 100.0).ToString("#.##"); //result: 567.89
string str12 = (56789 / 100).ToString("#.##"); //result: 567
字符 | 说明 | 示例 | 输出 |
---|---|---|---|
C 或 c | 货币 | Console.Write("{0:C}", 2.5); Console.Write("{0:C}", -2.5); | $2.50 ($2.50) |
D 或 d | 十进制数 | Console.Write("{0:D5}", 25); | 00025 |
E 或 e | 科学型 | Console.Write("{0:E}", 250000); | 2.500000E+005 |
F 或 f | 固定点 | Console.Write("{0:F2}", 25); Console.Write("{0:F0}", 25); | 25.00 25 |
G 或 g | 常规 | Console.Write("{0:G}", 2.5); | 2.5 |
N 或 n | 数字 | Console.Write("{0:N}", 2500000); | 2,500,000.00 |
X 或 x | 十六进制 | Console.Write("{0:X}", 250); Console.Write("{0:X}", 0xffff); | FA FFFF |
int s = 100;
byte[] shi = System.BitConverter.GetBytes(s);
int sh = System.BitConverter.ToInt32(shi, 0);
int[] a = new int[1];
a[0] = 100;
int[] b = new int[1];
System.Collections.BitArray shit = new BitArray(a);
shit.CopyTo(b, 0);
this.SetStyle(ControlStyles.DoubleBuffer |
ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint,
true);
this.UpdateStyles();
String name = Dns.GetHostName();
IPHostEntry ips = Dns.GetHostByName(name);
return ips.AddressList[0].ToString();
FileStream fileStream = new FileStream(pFileName, FileMode.Open);
long fileSize = fileStream.Length;
Context.Response.ContentType = "application/octet-stream";
Context.Response.AddHeader("Content-Disposition", "attachment; filename=/"" + fileName + "/";");
Context.Response.AddHeader("Content-Length", fileSize.ToString());
byte[] fileBuffer = new byte[fileSize];
fileStream.Read(fileBuffer, 0, (int) fileSize);
Context.Response.BinaryWrite(fileBuffer);
Context.Response.End();
int num = 123;
string str = Convert.ToString(num, 16);
string str = "7b";
int num = Convert.ToInt32(str,16);
<html>
<head>
<title>DHTML 编辑控件代理示例title>
<script type="text/javascript">
function FillEditor() {
var doc = editor.document;
doc.designMode = "on";
doc.write("可视化 安静
");
doc.close();
}
script>
head>
<body οnlοad="FillEditor()">
<iframe id="editor" scrolling="yes" height="100" width="300">
iframe>
<p>
<input type=button
value="Submit"
οnclick=
"alert(editor.document.getElementsByTagName('HTML')[0].outerHTML)">
body>
html>