SunQuest
 
       .NET
  Home arrow .NET arrow Knowing Your Environment: the System.Envir...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
VeriSign Whitepapers 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
.NET

Knowing Your Environment: the System.Environment Class
By: Ayad Boudiab
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2008-05-12

    Table of Contents:
  • Knowing Your Environment: the System.Environment Class
  • More Properties
  • More Explanations
  • Methods

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Knowing Your Environment: the System.Environment Class


    (Page 1 of 4 )

    When developing applications (Windows or web), it is very important for the developer to know the environment in which the application is running. Having this information will help the developer customize the software and make the user experience more enjoyable. In this regard, .NET provides a class in the System namespace called Environment, which is the subject of this article.

    The environment class contains methods and properties that provide information about the current environment and platform. It is important to note that this class cannot be inherited. In other words, you cannot extend the functionality in this class to create your own class.

    Here is a rundown of some of the handy methods and properties that this class provides, with minor explanation on the usage of each.

    Properties

    CommandLine: The call to Environment.CommandLine will provide the full name of the application, followed by the command line arguments. The command line arguments are the pieces of data entered after the application name. For example:


    Multiply.exe x1 x2


    In this case, x1 and x2 are the command line arguments. In order to get access to x1 and x2, you use the args array passed to the Main method. Here is the method signature:


    static   void Main( string [] args)


    Visual Studio provides two ways to enter the command line arguments:

    1. By running the application from the command prompt.

    2. By entering the arguments in the Debug tab of the project properties:



    Here is a statement that shows how you access the CommandLine property:


    //returns a string containing command-line arguments

    Console .WriteLine( "The command line is: " + Environment .CommandLine);

    More .NET Articles
    More By Ayad Boudiab


       · Hello everyone,Here is my latest article on the System.Environment class.Please...
     

    .NET ARTICLES

    - Mouse Input and the WPF
    - Input with Windows Presentation Foundation
    - Introducing LINQ with XML and Databases
    - An Introduction to LINQ
    - Querying LINQ to SQL: Basics
    - Completing a Simple Storefront with LINQ
    - Knowing Your Environment: the System.Environ...
    - Creating the Home Page for a Simple Storefro...
    - LINQ Quickly with Language Integrated Queries
    - Introducing LINQ to SQL Designer using Visua...
    - Beginning LINQ to SQL Using Visual Studio 20...
    - Coding an AjaxPro.NET Based Search Engine fo...
    - Building an AjaxPro.NET Based Search Engine ...
    - Delving Deeper into Serialization with .NET
    - Serialization with .NET





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway