Using JScript.NET to make asp.net Web page Basics Tutorial 2

Source: Internet
Author: User
Tags glob numeric
In order to implement the JScript.NET inference variable type function, you need to follow the following rules!
A Always declare your local variables. This may seem obvious, but it's very important that JScript.NET only infer your local variables, not the global variables. If you don't declare it, use it directly, it will become a global variable and it will not be optimized.
Two Using only one data type, if you declare a numeric variable and use it to store character-type data, JScript defines the variable as generic Object or Variant.
Cannot infer type--Glob is a global variable
var glob = 42;
function MyFunc ()
{
Cannot infer type--S is not defined so it is treated as a global variable
s = "Hello";
Types can be inferred
var i = 0;
Cannot infer type-Q is assigned to another type
var q = new Date ();
Q = 3.14159;
}
Although type inference is a very good feature, it has some drawbacks. It does not help us to capture type mismatches or other errors. To solve this problem, JScript.NET provides a way to explicitly define the type of a variable. By example, you will easily understand how it is used.
Defining numeric types
var myint:int = 42;
Defines a function that returns a string
function GetName (): String
{
Program Line
}
Defines a function with two parameters to return a logical type
function CheckNumber (dval:double): Boolean
{
function code
}




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.