I’d like to provide you with a SilverBullet™, a small snippet of Silverlight, a class or namespace hidden in the silverlight .NET framework, to help you out in times of need. It’s not to learn, but something to keep in your pocket. Just remember it’s there and you’re safe.
This first SilverBullet™ I would like to give you is the Environment class. It’s in the System namespace and provides information about the environment your application is running in. Use it to get information about the system, like command-line arguments, version of the CLR and the time the system is running. Some properties and methods in this class are used internally and can cause security risks. These properties and methods will throw an MethodAccessException. All properties are static.
The properties that can be used are:
- Environment.ExitCode; a 32-bit int containing the current exit code.
- Environment.HasShutdownStarted; a bool indicating the CLR is shutting down or the appdomain is unloading.
- Environment.NewLine; a string containing the local systems newline characters, this is different on unix and windows.
- Environment.OSVersion; an OperatingSystem object containing a platform id and version.
- Environment.TickCount; a long containing the amount of milliseconds since the system started.
- Environment.Version; a Version object describing the version of the CLR.
If you have any suggestions for another SilverBullet™, please let me know.