Your SlideShare is downloading. ×
0
2310 b 03
2310 b 03
2310 b 03
2310 b 03
2310 b 03
2310 b 03
2310 b 03
2310 b 03
2310 b 03
2310 b 03
2310 b 03
2310 b 03
2310 b 03
2310 b 03
2310 b 03
2310 b 03
2310 b 03
2310 b 03
2310 b 03
2310 b 03
2310 b 03
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

2310 b 03

669

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
669
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
48
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Module 3: Using Microsoft .NET- Based Languages
  • 2. Overview <ul><li>Overview of the .NET-Based Languages </li></ul><ul><li>Comparison of the .NET-Based Languages </li></ul><ul><li>Creating a Component Using Visual Studio .NET </li></ul>
  • 3. Lesson: Overview of the .NET-Based Languages <ul><li>Multiple Language Support </li></ul><ul><li>The Common Language Runtime </li></ul><ul><li>The Common Language Runtime Components </li></ul><ul><li>Runtime Compilation and Execution </li></ul><ul><li>What are Namespaces? </li></ul><ul><li>Using Namespaces </li></ul>
  • 4. Multiple Language Support <ul><li>The .NET Framework is designed to support many languages </li></ul><ul><ul><li>More than 20 languages currently supported </li></ul></ul><ul><ul><li>Microsoft provides Visual Basic .NET, C#, Visual J# .NET, and JScript .NET </li></ul></ul><ul><li>Benefits of multiple-language support </li></ul><ul><ul><li>Code modules are reusable </li></ul></ul><ul><ul><li>API access is the same for all languages </li></ul></ul><ul><ul><li>The right language is used for the right task </li></ul></ul><ul><ul><li>Performance is roughly equal between all languages </li></ul></ul>
  • 5. The Common Language Runtime <ul><li>One runtime for all . NET-Based Languages </li></ul><ul><li>Manages threads and memory </li></ul><ul><ul><li>Garbage collection </li></ul></ul><ul><li>Enforces code security </li></ul><ul><li>Eliminates DLL versioning problems </li></ul><ul><ul><li>Multiple versions of a DLL can run simultaneously </li></ul></ul><ul><ul><li>Applications can specify a version of a DLL to use </li></ul></ul>
  • 6. The Common Language Runtime Components .NET Framework Class Library Support Thread Support COM Marshaler MSIL to Native Compilers Code Manager Garbage Collector Security Engine Debug Engine Class Loader Type Checker Exception Manager
  • 7. Runtime Compilation and Execution Native code C# code Visual Basic .NET code default.aspx Runtime HTML Which language? Visual Basic .NET compiler C# compiler MSIL JIT compiler
  • 8. What are Namespaces? <ul><li>Group related classes </li></ul><ul><ul><li>Logical, not physical, grouping </li></ul></ul><ul><ul><li>Namespaces are hierarchical </li></ul></ul><ul><li>Decrease naming conflicts </li></ul><ul><li>Imports keyword in Visual Basic .NET code </li></ul><ul><li>Using keyword in C# code </li></ul>Imports System.Data.SqlClient using System.Data.SqlClient;
  • 9. Using Namespaces <ul><li>Implicit object declaration </li></ul><ul><li>Explicit object declaration </li></ul>Dim listBox1 As New System.Web.UI.WebControls.ListBox() listBox1.Items.Add(&quot;First Item&quot;) Imports System.Web.UI.WebControls ... Dim listBox1 As New ListBox() listBox1.Items.Add(&quot;First Item&quot;) using System.Web.UI.WebControls; ... ListBox listBox1 = new ListBox(); listBox1.Items.Add(&quot;First Item&quot;); System.Web.UI.WebControls.ListBox listBox1 = new System.Web.UI.WebControls.ListBox(); listBox1.Items.Add(&quot;First Item&quot;);
  • 10. Lesson: Comparison of the .NET-Based Languages <ul><li>Visual Basic .NET </li></ul><ul><li>C# </li></ul><ul><li>Choosing a Language </li></ul><ul><li>Practice: Language Translation </li></ul>
  • 11. Visual Basic .NET <ul><li>Visual Basic .NET is the latest version of Visual Basic </li></ul><ul><li>True object-oriented language </li></ul><ul><li>Visual Basic Scripting Edition (and JScript) are still used for client-side script </li></ul>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 & x & &quot;,&quot; Next End Sub
  • 12. C# <ul><li>C# is a new language </li></ul><ul><li>Similar to Java, Visual C++, and Pascal </li></ul>private void Button1_Click(object sender, System.EventArgs e) { int i = 0; double x = Convert.ToDouble(TextBox1.Text); for (i=0; i<=4; i++) { x *= 2; Label1.Text = Label1.Text + x + &quot;,&quot;; } }
  • 13. Choosing a Language <ul><li>.NET Framework class library is the same regardless of language </li></ul><ul><li>Performance </li></ul><ul><ul><li>All languages are compiled to MSIL </li></ul></ul><ul><ul><li>Only performance difference is how each language compiler compiles to MSIL </li></ul></ul><ul><ul><li>The runtime compiles all MSIL the same, regardless of its origin </li></ul></ul><ul><li>Development experience </li></ul><ul><ul><li>C# is similar to Java, C, Visual C++, and Pascal </li></ul></ul><ul><ul><li>Visual Basic .NET is similar to Visual Basic </li></ul></ul><ul><li>Browser compatibility </li></ul><ul><ul><li>ASP.NET code is server-side code, so browser compatibility is not an issue </li></ul></ul>
  • 14. Practice: Language Translation <ul><li>Students are: </li></ul><ul><ul><li>Given code in C#, and will then translate it into Visual Basic .NET </li></ul></ul><ul><ul><li>Given code in Visual Basic .NET, and will then translate it into C# </li></ul></ul><ul><li>Time: 5 minutes </li></ul>
  • 15. Lesson: Creating a Component Using Visual Studio .NET <ul><li>What are Classes and Components? </li></ul><ul><li>Creating a Class </li></ul><ul><li>Using Components in an ASP.NET Web Form </li></ul><ul><li>Demonstration: Creating a Class in Visual Studio .NET </li></ul>
  • 16. What are Classes and Components? <ul><li>Classes are groups of code with no user interface </li></ul><ul><li>Components are compiled classes </li></ul><ul><ul><li>Components are compiled as DLL files </li></ul></ul><ul><li>Components are used for sharing code between applications </li></ul>Web application Windows application Web application component
  • 17. <ul><li>Create a Class Library project in Visual Studio .NET </li></ul><ul><ul><li>Visual Studio .NET creates a default namespace </li></ul></ul><ul><li>Create methods of the class </li></ul>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 sngPrice) { //… return sngShipping; } }
  • 18. Using Components in an ASP.NET Web Form <ul><li>Add a reference to the DLL </li></ul><ul><li>Instantiate the class object: </li></ul><ul><li>Use the object: </li></ul>sngShipping = x.ShippingCost(sngPrice); Dim x As New CompanyA.Shipping Namespace CompanyA Class Shipping Function ShippingCost (…) End Class End Namespace component.dll sngShipping = _ x.ShippingCost(sngPrice) CompanyA.Shipping x = new CompanyA.Shipping(); namespace CompanyA { class Shipping { public void ShippingCost (…) { } } } component.dll
  • 19. Demonstration: Creating a Class in Visual Studio .NET <ul><li>Create a new Class Library project </li></ul><ul><li>Create a “Hello World” method </li></ul><ul><li>Call it from an ASP.NET page </li></ul>
  • 20. Review <ul><li>Overview of the .NET-Based Languages </li></ul><ul><li>Comparison of the .NET-Based Languages </li></ul><ul><li>Creating a Component Using Visual Studio .NET </li></ul>
  • 21. Lab 3: Building a Microsoft Visual Studio .NET Component Medical Medical.aspx Benefits Home Page Default.aspx Life Insurance Life.aspx Retirement Retirement.aspx Dental Dental.aspx Dentists Doctors Doctors.aspx Doctors Logon Page Login.aspx Registration Register.aspx Coho Winery Prospectus Prospectus.aspx XML Web Service dentalService1.asmx Page Header Header.ascx ASPState tempdb Lab Web Application User Control namedate.ascx Menu Component Class1.vb XML Files Web. config Medical Medical.aspx Benefits Home Page Default.aspx Life Insurance Life.aspx Retirement Retirement.aspx Dental Dental.aspx Dentists Doctors Doctors.aspx Doctors Logon Page Login.aspx Registration Register.aspx Prospectus Prospectus.aspx XML Web Service dentalService1.asmx Page Header Header.ascx ASPState tempdb Lab Web Application User Control namedate.ascx Menu Component Class1.vb or Class1.cs XML Files Web. config

×