October 23, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

Introducing the .NET Framework and JScript .NET

  • December 6, 2001
  • By Essam Ahmed
  • Send Email »
  • More Articles »

Visual Studio .NET

Visual Studio .NET fulfills the promise of a unified development environment for .NET programming languages. Visual Studio .NET combines the best of Visual Basic, Visual C++, and Visual InterDev development environments and adds some great new features. Tools like the Visual Basic forms editor, Visual Modeler, an XML editor, a To Do list, and a new dynamic help system are available for all supported languages (like Visual C# .NET, Visual Basic .NET, and Visual C++ .NET).

Introducing JScript .NET

JScript .NET is the single most significant upgrade to JScript since it was first introduced in 1996 in Internet Explorer 3.0. JScript .NET is a flexible, powerful programming that you can use to create everything from simple scripts to full-blown Windows or Web-based applications. JScript .NET preserves your investment in JScript by maintaining 100% backwards compatibility with existing JScript code.

JScript .NET is fully object-oriented programming language, offering support for classes, inheritance, polymorphism, function overloading, and many other modern features. JScript .NET maintains its easy to use nature by allowing you to take advantage of new language features as you become familiar with them. For example, even though JScript .NET supports typed variables, you're still free to not even declare variables before using them. JScript .NET is the only other standardized language currently available on the .NET Platform (C++ is the other standardized language) - standardization is your assurance of on-going multi-vendor support for JScript .NET.

The following listing demonstrates some of JScript .NET's new features:

// create a new package (namespace)
package jsnetSample {

  // declare a new class
  class jsnetClass 
  {
    // static member variable - a variable that can 
    // exist without a class
    public static var staticString : String;

    // Note the staticString declaration above - it 
    // is a String variable 
  
    // Sample member function - takes a string argument 
    // and return an int
    // The declaration of the function's parameter type 
    // is similar to declaring a variable...
    public function methodOne(param1 : String) : int {
    
      // declare a variable and initialize it
      var i : int = 5;
      // call a .NET Class Library method to send output 
      // to the console
      Console.WriteLine("Hello {0}\n",param1);
      return i;
    }

    // overload methodOne for to take int parameter and 
    // return a String (reverse of original method)...
    public function methodA(param1 : int) : String {
      //...
      return "this is a string"; 
    }

    // delcare a private member function
    // Private member functions are accessible only by the
    // class that declares the function...
    private function privateMethod() {
      //...
    }
    // Static initializer - initialies static variables even
    // without an instance of the class avaialble at runtime...
    static {
      sampleString = "This is a static initializer"; 
    }
  } // end of the class
} // end of the package

The listing demonstrates the following features:

  • The package statement to create a new namespace
  • The class statement
  • Typed and static variables
  • Member functions
  • Function overloading
  • Working with the .NET Class Library

Summary

This article introduced you to the .NET Platform, which is made up of four key components including the Common Language Runtime, ASP.NET and Visual Studio .NET. This article also introduced you to JScript .NET and demonstrated some of its new features using some sample code. The next installment of this series discusses all of JScript .NET's new features.


Essam Ahmed is the author of "JScript .NET Programming" (ISBN 0764548689, Published by Hungry Minds September 2001), many articles (including some at CodeGuru.com) and book reviews (also available at CodeGuru.com). Contact Essam at essam@designs2solutions.com, or at his Web site





Page 2 of 2



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 



Rocket Fuel