Theory
button ને build ન કરો
think કરો કે ShopKeeper ને શું જોઈએ છે: windows, buttons, textboxes, bill grid, file saving, database connection, date handling, string cleanup.
button ને scratch થી writing કરવું (pixels draw કરવા, clicks track કરવા, hover પર repainting) તમને એક month લેતું. અને તે તમારું button હોત, તમારા bugs સાથે.
Microsoft એ already button ને લખ્યું છે. અને grid, file reader, connection ને પણ. .NET નો second pillar એ warehouse છે: Framework Class Library.
Theory
library, ઔપચારિક રીતે
.NET Framework Class Library (FCL) એ comprehensive, object-oriented collection છે reusable classes, interfaces અને types ની, identically available દરેક .NET language ને.
તેનું organising system એ namespace છે: dotted, hierarchical name જે related classes ને group કરે છે, exactly BCA403 ના Java packages જેવું.
Systemએ root છે: everyday types અહીં live કરે છેSystem.Windows.Formsdesktop UI classes ને hold કરે છેSystem.Datadatabase machinery ને hold કરે છે
Deep dots એ more specialised shelf નો અર્થ છે, nothing more.
At a glance
shelves જે ShopKeeper visit કરશે
| Namespace | શું shelf પર છે | ShopKeeper use |
|---|---|---|
| System | Object, String, Int32, Math, Console | દરેક line of code |
| System.Windows.Forms | Form, Button, TextBox, DataGrid | billing screen (Unit 3) |
| System.Data | Connection, Command, DataSet | bills saving (Unit 5) |
| System.IO | File, StreamReader, StreamWriter | day ના report ને export કરવું |
| System.Collections | ArrayList અને friends | bill માં items ની list (Unit 2) |
Practical
Imports shelf ને open કરે છે
' Without Imports: full names everywhere
Dim box1 As System.Windows.Forms.TextBox
' With Imports file ની top પર:
Imports System.Windows.Forms
Public Class BillingForm
Dim box2 As TextBox ' short name હવે work કરે છે
Dim total As Integer ' Integer નીચે System.Int32 IS છે
Sub Greet()
MsgBox("Welcome to ShopKeeper")
End Sub
End Class
Quiz
ShopKeeper ને તેના Form, Button અને TextBox classes માટે કયા namespace માં reach કરવું જોઈએ?
- System.Windows.Forms
- System.Data
- System.IO
- Microsoft.VisualStudio
Show the answer
System.Windows.Forms
Desktop UI System.Windows.Forms shelf પર lives કરે છે; Unit 3 એ essentially તેનો guided tour છે. System.Data એ Unit 5 માટે database machinery છે, System.IO એ files અને streams છે. Microsoft.VisualStudio એ trap છે: Visual Studio એ IDE છે જેમાં તમે sit કરો છો, અને તમારું running program તેના પર depend નથી કરતું; tool ને library સાથે confuse કરવું એ recurring Unit 1 mistake છે.
Think first
Integer, really શું છે?
VB.NET લખે છે Dim total As Integer, C# લખે છે int total. yesterday ના lesson એ કહ્યું કે બંને languages એક type system ને share કરે છે. tap કરતા પહેલા: Integer નીચે શું છે, અને શા માટે તે matter કરે છે?
Show the answer
Integer એ alias છે System.Int32 નો, class-library type; C# નો int એ SAME System.Int32 છે. દરેક language keyword-type એક FCL type પર maps થાય છે: String એ System.String છે, Boolean એ System.Boolean છે. એ CTS છે જે concrete બન્યું છે: languages types ને share કરે છે by all borrowing from one warehouse. Consequence જે તમે constantly use કરશો: Integer ની પાસે METHODS છે (total.ToString()), કારણ કે નીચે તે ક્યારેય bare C-style int નહોતું.
Watch out
Library confusions જે marks cost કરે છે
FCL vs CLR: library એ parts છે, CLR એ engine છે. "class library executes MSIL" 0 scores કરે છે.
Imports code ને load નથી કરતું: Java ના import જેવું, તે ફક્ત તમને short names લખવા દે છે; assembly reference actual linking કરે છે.
Namespace vs class: System.Windows.Forms એ namespace છે; Form એ class છે તેની અંદર. "Form namespace" લખવું examiner ને કહે છે કે તમે ક્યારેય IDE ને touch નથી કર્યું.
Theory
Unit 1 એક breath માં
તમે હવે આખી machine ને recite કરી શકો છો: VB.NET source MSIL + metadata માં compile થાય છે assembly માં; CLR તેને load, verify, JIT-compile અને garbage-collect કરે છે; અને code itself મોટાભાગે FCL classes માંથી assembled છે જે namespaces દ્વારા reached છે. twice કહો; તે 4 different exam questions ને answer કરે છે. next lesson તમે finally Visual Studio ને open કરો છો અને room ને meet કરો છો જ્યાં ShopKeeper build થાય છે.
Summary
Key takeaways
- FCL એ .NET ની library છે ready-made classes ની, all .NET languages દ્વારા identically shared.
- Namespaces તેને hierarchically organise કરે છે: System root પર, dots specialisation માટે.
- Key shelves: System (core types), System.Windows.Forms (UI), System.Data (ADO.NET), System.IO (files), System.Collections.
- Imports namespace ને scope માં લાવે છે short names માટે, Java ના import જેવું.
- VB.NET ના Integer/String એ FCL types ના aliases છે (System.Int32, System.String): practice માં CTS.
- Library = parts, CLR = engine; answer માં ક્યારેય તેમના jobs ને swap ન કરો.
- Memory hook: ક્યારેય build ન કરો જે warehouse already stock કરે છે.