Environment Class in C#

The following function displays some of the methods and properties of the Environment class of C#


static void ShowEnvironmentInfo()

{

Console.WriteLine("Commandline: {0}", Environment.CommandLine);

Console.WriteLine("Current directory: {0}", Environment.CurrentDirectory);

Console.WriteLine("Machine name: {0}", Environment.MachineName);


Console.WriteLine("OS: {0}", Environment.OSVersion);


Console.WriteLine("Userdomain name: {0}", Environment.UserDomainName);

foreach (string drive in Environment.GetLogicalDrives())

Console.WriteLine("Drive: {0}", drive);

Console.WriteLine("Number of processors: {0}", Environment.ProcessorCount);



Console.WriteLine(".NET Version: {0}", Environment.Version);

Console.WriteLine("Command arguments: {0}", Environment.GetCommandLineArgs());

}


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: