Today, I would like to show you a hello World.
Is the most simplified hello.
First, the simplest configuration of Web. config is as follows:
Explain in
Code .
[Copy to clipboard]
Code:
<Configuration>
<System. Web>
<Compilation DEBUG = "false">
<Assemblies>
<Add Assembly = "system. Core, version = 3.5.0.0, culture = neutral, publickeytoken = b77a5c561934e089"/>
</Assemblies>
</Compilation>
</System. Web>
<System. codedom>
<Compilers>
<Compiler language = "C #; CS; CSHARP" extension = ". cs" WarningLevel = "4" type = "Microsoft. CSHARP. csharpcodeprovider, system,
Version = 2.0.0.0, culture = neutral, publickeytoken = b77a5c561934e089 ">
<Provideroption name = "compilerversion" value = "v3.5"/>
</Compiler>
</Compilers>
</System. codedom>
</Configuration>
The following is an explanation. System. Core. dll contains system. LINQ, so this Assembly must be added,
Of course, this Assembly may not be on the web. add the token in config, that is, the token. the Web can be removed, but you need to use the old <% @ register tagprefix = "SC" namespace = "system. LINQ "assembly =" system. core "%> and add System in Bin. core. DLL file.
The second focus is to tell him to use the v3.5 compiler. Because ASP. net3.5 actually uses ASP. after net2.0 is installed, IIS still displays 3.5. in the config file, you need to describe how to use 3.5. Otherwise, he will not recognize the VaR xxx = from cloud of LINQ.
The following is the aspx subject:
[Copy to clipboard]
Code:
<% @ Page Language = "C #" autoeventwireup = "true" %>
<% @ Import namespace = "system. LINQ" %>
<Script language = "C #" runat = "server">
Protected void page_load (Object sender, eventargs E)
{
Txtvalidated. Text = "SIPO (www.51aspx.com), and finally output :";
Int [] testnums = {787,321, 22, 1,-83 };
VaR Nums = from S in testnums where S <5 select s;
Foreach (var c in Nums) txtvalidated. Text ++ = C + ",";
}
</SCRIPT>
<Form runat = "server">
<Asp: textbox id = "txtvalidated" runat = "server" width = "800"/>
</Form>
Codebehind is not used because it saves some space. Helloworld ~ One file.
Autoeventwireup = "true" means to execute the page_load event, otherwise it will not be executed.
Here we need to import system. LINQ and use using in the CS file.
Then there is nothing to say (Author: SIPO ).