Table of Contents [Hide/Show]
Environment Username Computer Name Computer Name, Fully Qualified with Domain Name Network IP Address Ping Operation Default Gateway Other Hourglass/Default Cursor ASCII Codes New GUID Sleep Detecting Design-Time Resources Embedded Resources Threading Escaping XML Characters Time Remaining Calling Method
//for Windows applications System.Environment.UserName //for Web applications HttpContext.Current.User.Identity.Name
// Option #1 System.Environment.MachineName // Option #2 System.Net.Dns.GetHostName()
System.Net.Dns.GetHostEntry(Environment.MachineName).HostName
System.Net.Dns.GetHostAddresses(string hostName)[0]
using System.Net.NetworkInformation; . . . try { new Ping().Send(address).Status == IPStatus.Success } catch (Exception ex) { }
using System.Net.NetworkInformation; using System.Net; . . . List<IPAddress> addresses = new List<IPAddress>(); foreach (NetworkInterface networkCard in NetworkInterface.GetAllNetworkInterfaces()) { GatewayIPAddressInformationCollection gateways = networkCard.GetIPProperties().GatewayAddresses; foreach (GatewayIPAddressInformation gateway in gateways) addresses.Add(gateway.Address); }
this.Cursor = Cursors.WaitCursor; this.Cursor = Cursors.Default;
char c; int asciiCode = (int)c;
System.Guid.NewGuid().ToString()
System.Threading.Thread.Sleep(ms)
System.Diagnostics.Debugger.IsAttached = true;
picHide.Image = (System.Drawing.Image) // Note that resourceName IS CASE-SENSITIVE! Resources.ResourceManager.GetObject(resourceName);
Cursor result = null; /* resourceName follows the format * Namespace.Folder.Resources.FileName */ string resourceName = "MyApp.Resources.SelectTextLine.cur"; Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName); if (s != null) result = new Cursor(s);
using System.Threading; // starter.Start is the name of the object/method to call Thread t = new Thread(new ThreadStart(starter.Start)); t.Start();
System.Security.SecurityElement.Escape(inputText);
private static TimeSpan CalcTimeRemaining(int n, int m, TimeSpan elapsed) { double rate = elapsed.TotalMilliseconds / (double)n; double ms = ((double)m - (double)n) * rate; long ticks = (long)(ms * 10000); TimeSpan remaining = new TimeSpan(ticks); return remaining; }
System.Reflection.MethodBase caller = new System.Diagnostics.StackTrace(1, false).GetFrame(0).GetMethod(); string s = caller.Name;
ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.