NET 系列教程2310B_03.ppt_第1页
NET 系列教程2310B_03.ppt_第2页
NET 系列教程2310B_03.ppt_第3页
NET 系列教程2310B_03.ppt_第4页
NET 系列教程2310B_03.ppt_第5页
已阅读5页,还剩17页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、Module 3:Using Microsoft .NET- Based Languages,Overview,Overview of the .NET-Based Languages Comparison of the .NET-Based Languages Creating a Component Using Visual Studio .NET,Lesson: Overview of the .NET-Based Languages,Multiple Language Support The Common Language Runtime The Common Language Run

2、time Components Runtime Compilation and Execution What are Namespaces? Using Namespaces,Multiple Language Support,The .NET Framework is designed to support many languages More than 20 languages currently supported Microsoft provides Visual Basic .NET, C#, Visual J# .NET, and JScript .NET Benefits of

3、 multiple-language support Code modules are reusable API access is the same for all languages The right language is used for the right task Performance is roughly equal between all languages,The Common Language Runtime,One runtime for all . NET-Based Languages Manages threads and memory Garbage coll

4、ection Enforces code security Eliminates DLL versioning problems Multiple versions of a DLL can run simultaneously Applications can specify a version of a DLL to use,The Common Language Runtime Components,.NET Framework Class Library Support,Thread Support,COM Marshaler,MSIL to Native Compilers,Code

5、 Manager,Garbage Collector,Security Engine,Debug Engine,Class Loader,Runtime Compilation and Execution,Nativecode,C# code,Visual Basic .NET code,default.aspx,Runtime,HTML,What are Namespaces?,Group related classes Logical, not physical, grouping Namespaces are hierarchical Decrease naming conflicts

6、Imports keyword in Visual Basic .NET code Using keyword in C# code,Imports System.Data.SqlClient,using System.Data.SqlClient;,Using Namespaces,Implicit object declaration Explicit object declaration,Dim listBox1 As New System.Web.UI.WebControls.ListBox() listBox1.Items.Add(First Item),Imports System

7、.Web.UI.WebControls . Dim listBox1 As New ListBox() listBox1.Items.Add(First Item),using System.Web.UI.WebControls; . ListBox listBox1 = new ListBox(); listBox1.Items.Add(First Item);,System.Web.UI.WebControls.ListBox listBox1 = new System.Web.UI.WebControls.ListBox(); listBox1.Items.Add(First Item)

8、;,Lesson: Comparison of the .NET-Based Languages,Visual Basic .NET C# Choosing a Language Practice: Language Translation,Visual Basic .NET,Visual Basic .NET is the latest version of Visual Basic True object-oriented language Visual Basic Scripting Edition (and JScript) are still used for client-side

9、 script,Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click Dim i As Integer = 0 Dim x As Double = TextBox1.Text For i = 0 To 4 x *= 2 Label1.Text = Label1.Text double x = Convert.ToDouble(TextBox1.Text); for (i=0; i=4; i+) x *= 2; Label1.Tex

10、t = Label1.Text + x + ,; ,Choosing a Language,.NET Framework class library is the same regardless of language Performance All languages are compiled to MSIL Only performance difference is how each language compiler compiles to MSIL The runtime compiles all MSIL the same, regardless of its origin Dev

11、elopment experience C# is similar to Java, C, Visual C+, and Pascal Visual Basic .NET is similar to Visual Basic Browser compatibility ASP.NET code is server-side code, so browser compatibility is not an issue,Practice: Language Translation,Students are: Given code in C#, and will then translate it

12、into Visual Basic .NET Given code in Visual Basic .NET, and will then translate it into C# Time: 5 minutes,Lesson: Creating a Component Using Visual Studio .NET,What are Classes and Components? Creating a Class Using Components in an ASP.NET Web Form Demonstration: Creating a Class in Visual Studio

13、.NET,What are Classes and Components?,Classes are groups of code with no user interface Components are compiled classes Components are compiled as DLL files Components are used for sharing code between applications,Web application,Windows application,Web application,Create a Class Library project in

14、 Visual Studio .NET Visual Studio .NET creates a default namespace Create methods of the class,Creating a Class,Public Class Shipping Function ShippingCost _ (ByVal sngPrice As Single) As Single Return (sngShipping) End Function End Class,public class Shipping public Single ShippingCost (Single sngP

15、rice) / return sngShipping; ,Using Components in an ASP.NET Web Form,Add a reference to the DLL Instantiate the class object: Use the object:,sngShipping = x.ShippingCost(sngPrice);,Dim x As New CompanyA.Shipping,Namespace CompanyA Class Shipping Function ShippingCost () End ClassEnd Namespace,compo

16、nent.dll,sngShipping = _ x.ShippingCost(sngPrice),CompanyA.Shipping x = new CompanyA.Shipping();,namespace CompanyA class Shipping public void ShippingCost () ,component.dll,Demonstration: Creating a Class in Visual Studio .NET,Create a new Class Library project Create a “Hello World” method Call it

17、 from an ASP.NET page,Review,Overview of the .NET-Based Languages Comparison of the .NET-Based Languages Creating a Component Using Visual Studio .NET,Lab 3: Building a Microsoft Visual Studio .NET Component,MedicalMedical.aspx,BenefitsHome PageDefault.aspx,Life InsuranceLife.aspx,RetirementRetireme

18、nt.aspx,DentalDental.aspx,Dentists,DoctorsDoctors.aspx,Doctors,Logon Page Login.aspx,Registration Register.aspx,CohoWinery,ProspectusProspectus.aspx,XML Web ServicedentalService1.asmx,Page HeaderHeader.ascx,ASPState,tempdb,Lab Web Application,User Controlnamedate.ascx,Menu ComponentClass1.vb,XML Files,Web.config,MedicalMedical.aspx,BenefitsHome PageDefault.aspx

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论