SlideShare a Scribd company logo
1 of 52
Introduction to .NETIntroduction to .NET
JoniJoni
ATL - Bina NusantaraATL - Bina Nusantara
Session PrerequisitesSession Prerequisites
• This session assumes that you familiarThis session assumes that you familiar
with:with:
– Component-Based or Object-OrientedComponent-Based or Object-Oriented
DevelopmentDevelopment
– Java, Visual C++ or Visual BasicJava, Visual C++ or Visual Basic
programming languageprogramming language
AgendaAgenda
• .NET Framework.NET Framework
– GoalsGoals
– .NET Platform.NET Platform
– .NET Compact Framework.NET Compact Framework
• C#C#
– What is C#What is C#
– The Development of C#The Development of C#
.NET Framework.NET Framework
GoalsGoals
• DevelopmentDevelopment
– First-class support for componentsFirst-class support for components
– Standard class frameworkStandard class framework
– Automatic memory managementAutomatic memory management
– Consistent error handlingConsistent error handling
– Mixed language applicationsMixed language applications
– Multiple platformsMultiple platforms
– Safer executionSafer execution
• DeploymentDeployment
– Removal on registration dependencyRemoval on registration dependency
– Safety – fewer versioning problemsSafety – fewer versioning problems
– The end of ‘DLL Hell’The end of ‘DLL Hell’
.NET Platform.NET Platform
•.NET experiences are XML Web.NET experiences are XML Web
services that allow you to accessservices that allow you to access
information across the Internet andinformation across the Internet and
from standalone applications in anfrom standalone applications in an
integrated way.integrated way.
•Some of the products that MicrosoftSome of the products that Microsoft
is transitioning into .NETis transitioning into .NET
experiences are MSN, bCentral,experiences are MSN, bCentral,
PassportPassport
•Clients are all smart devices such as
PCs, laptops, workstations, phones,
handheld computers
•Some of the .NET client software
Microsoft will offer are Windows CE,
Windows Embedded, Window 2000,
Windows XP, Windows Server 2003
•A core set of building block
services that perform routine tasks
and act as the backbone for
developers to build upon.
•.NET My Services(HailStorm)
•Microsoft Windows Server 2003
•Microsoft Application Center 2000
•Microsoft BizTalk™ Server 2000
•Microsoft Commerce Server 2000
•Microsoft Content Management Server 2001
•Microsoft Exchange Server 2000
•Microsoft Host Integration Server 2000
•Microsoft Internet Security and Acceleration
Server 2000
•Microsoft Mobile Information 2001 Server
•Microsoft SharePoint™ Portal Server 2001
•Microsoft SQL Server™ 2000
•The Microsoft .NET Framework
SDK
•Microsoft Visual Studio.NET 2002
•Microsoft Visual Studio.NET 2003
The .NET FrameworkThe .NET Framework
Operating SystemOperating System
Common Language RuntimeCommon Language Runtime
Base Class LibraryBase Class Library
ADO.NET and XMLADO.NET and XML
ASP.NETASP.NET
Web Forms, Web Services,Web Forms, Web Services,
Mobile Web ApplicationMobile Web Application
WindowsWindows
FormsForms
Common Language SpecificationCommon Language Specification
VBVB C++C++ C#C# JScriptJScript ……
VisualStudio.NETVisualStudio.NET
.NET Framework and CLR.NET Framework and CLR
CLR Execution ModelCLR Execution Model
VBVBSourceSource
codecode
CompilerCompiler
C++C++C#C#
CompilerCompilerCompilerCompiler
AssemblyAssembly
IL CodeIL Code
AssemblyAssembly
IL CodeIL Code
AssemblyAssembly
IL CodeIL Code
Operating System ServicesOperating System Services
Common Language RuntimeCommon Language Runtime
JIT CompilerJIT Compiler
Native CodeNative Code
ManagedManaged
codecode
UnmanagedUnmanaged
ComponentComponent
The .NET Compact FrameworkThe .NET Compact Framework
• .NET will also be available on devices.NET will also be available on devices
– Cell phones, PDAs, others...Cell phones, PDAs, others...
• .NET Compact Framework will be....NET Compact Framework will be...
– FamiliarFamiliar
– Modular—only use pieces you needModular—only use pieces you need
– ExtensibleExtensible
– Cross-processorCross-processor
– Run on multiple OSesRun on multiple OSes
• Not just Windows CENot just Windows CE
The .NET Framework Class LibraryThe .NET Framework Class Library
• Accessible from any language targeting the CLRAccessible from any language targeting the CLR
• Written in C#Written in C#
• Organized into namespacesOrganized into namespaces
– All of which are below the System namespaceAll of which are below the System namespace
• Contains:Contains:
– ASP.NETASP.NET
– ADO.NETADO.NET
– Windows FormsWindows Forms
– Much, much moreMuch, much more
Common Type SystemCommon Type System
• Every languages that is CLS complianceEvery languages that is CLS compliance
use the same type that use through all theuse the same type that use through all the
frameworkframework
• This Type which is targeted by .NETThis Type which is targeted by .NET
compilers called Common Type Systemcompilers called Common Type System
• This makes sure that every type isThis makes sure that every type is
supported cross-language developmentsupported cross-language development
Unified Type SystemUnified Type System
• Traditional views of primitive typesTraditional views of primitive types
– C++, Java: They’re “magic”C++, Java: They’re “magic”
– Smalltalk, Lisp: They’re full-blown objectsSmalltalk, Lisp: They’re full-blown objects
• C# unifies with no performance costC# unifies with no performance cost
– Value types, boxing and unboxingValue types, boxing and unboxing
– Deep simplicity throughout systemDeep simplicity throughout system
• Improved extensibility and reusabilityImproved extensibility and reusability
– New primitive types: Decimal, SQL…New primitive types: Decimal, SQL…
– Collections, etc., work for all typesCollections, etc., work for all types
Illustrating the CTSIllustrating the CTS
Object
ValueType
Boolean
Byte
Char
Decimal
Double
Int16
Int32
Single
Int64
UInt16
UInt32
UInt64
Class
String
Array
Interface
Delegate
Value Types
Enum
Structure
Others Others
Value and Reference TypesValue and Reference Types
• Value typesValue types
– Variables directly contain dataVariables directly contain data
– Cannot be nullCannot be null
• Reference typesReference types
– Variables contain references to objectsVariables contain references to objects
– May be nullMay be null
int i = 123;int i = 123;
string s = "Hello world";string s = "Hello world";123123ii
ss "Hello world""Hello world"
Common Type SystemCommon Type System
• Conversion between each type:Conversion between each type:
Boxing ConversionBoxing Conversion
Convert Value Type to Reference TypeConvert Value Type to Reference Type
.NET creates appropriate dynamic type.NET creates appropriate dynamic type
to “box” the value type.to “box” the value type.
int i = 100;int i = 100;
object o = i;object o = i;
Common Type SystemCommon Type System
• Conversion between each type:Conversion between each type:
UnBoxing ConversionUnBoxing Conversion
Convert Reference Type to Value TypeConvert Reference Type to Value Type
int i = (int) o;int i = (int) o;
Common Language SpecificationCommon Language Specification
• Microsoft’s CLS describes minimum setMicrosoft’s CLS describes minimum set
of features that a CLR-compliantof features that a CLR-compliant
compiler must supportcompiler must support
• Note: the CLR supports more featuresNote: the CLR supports more features
than the CLS describesthan the CLS describes
– Using these features prevents inter-Using these features prevents inter-
language operabilitylanguage operability
.NET Framework and CLR.NET Framework and CLR
Garbage CollectionGarbage Collection
 Garbage collection is the process ofGarbage collection is the process of
automatically freeing up memory when anautomatically freeing up memory when an
object it been allocated to is no longerobject it been allocated to is no longer
being usedbeing used
.NET Framework and CLR.NET Framework and CLR
Benefits of Garbage CollectionBenefits of Garbage Collection
 Garbage collection prevents the followingGarbage collection prevents the following
errors:errors:
 Forgetting to destroy objectsForgetting to destroy objects
 Attempting to destroy the same object moreAttempting to destroy the same object more
than oncethan once
 Destroying an active objectDestroying an active object
myAssembly.DLLmyAssembly.DLL
.NET Framework and CLR.NET Framework and CLR
AssembliesAssemblies
myAssembly.DLLmyAssembly.DLL
Single ModuleSingle Module Multiple ModulesMultiple Modules
ManifestManifestManifestManifest
MetadataMetadataMetadataMetadata
IL CodeIL CodeIL CodeIL Code
Util.netmoduleUtil.netmodule
MetadataMetadataMetadataMetadata
IL CodeIL CodeIL CodeIL Code
Graphic.BMPGraphic.BMP
ResourcesResourcesResourcesResources
MetadataMetadataMetadataMetadata
IL codeIL codeIL codeIL code
ResourcesResourcesResourcesResources
ManifestManifestManifestManifest
.NET Framework and CLR.NET Framework and CLR
AssembliesAssemblies
• Advantages of Assemblies:Advantages of Assemblies:
– Self-DescribingSelf-Describing
– Side by Side executionSide by Side execution
– Ease of Deployment (avoid DLL-Hell)Ease of Deployment (avoid DLL-Hell)
– Ease of uninstallationEase of uninstallation
.NET Framework and CLR.NET Framework and CLR
AssembliesAssemblies
• Structure of an Assembly:Structure of an Assembly:
– ManifestManifest
– Type MetaDataType MetaData
– MSIL CodeMSIL Code
– Resources (optional)Resources (optional)
.NET Framework and CLR.NET Framework and CLR
ManifestManifest
• Data Structures stores details ofData Structures stores details of
an Assembly:an Assembly:
– Assembly Name and versionAssembly Name and version
– OS and Processor used to built toOS and Processor used to built to
– List of Dependencies filesList of Dependencies files
– Strong Name InformationStrong Name Information
.NET Framework and CLR.NET Framework and CLR
MetadataMetadata
• Type InformationType Information
– More complete than IDL / TLBMore complete than IDL / TLB
– Automatically bound into assemblyAutomatically bound into assembly
• InseparableInseparable
• Stored in binary formatStored in binary format
– Describes every class typeDescribes every class type
– Used by VS.NET IntelliSenseUsed by VS.NET IntelliSense™™
, compilers,, compilers,
runtime, etc.runtime, etc.
.NET Framework and CLR.NET Framework and CLR
AssembliesAssemblies
• Two kind of Assemblies:Two kind of Assemblies:
– Static AssembliesStatic Assemblies
• Persisted in diskPersisted in disk
• Most usedMost used
– Dynamic AssembliesDynamic Assemblies
• Build on the fly using Reflection APIBuild on the fly using Reflection API
• Exists in MemoryExists in Memory
• Can be converted to Static AssembliesCan be converted to Static Assemblies
• Less usedLess used
.NET Framework and CLR.NET Framework and CLR
AssembliesAssemblies
• Types of Static AssembliesTypes of Static Assemblies
– Single File AssembliesSingle File Assemblies
Using only one file to store all parts of anUsing only one file to store all parts of an
Assembly (Manifest, Metadata, IL, Res)Assembly (Manifest, Metadata, IL, Res)
– Multi File AssembliesMulti File Assemblies
Implementation of an Assembly split overImplementation of an Assembly split over
several files. Every part called .NET module.several files. Every part called .NET module.
• Using One or more assembliesUsing One or more assemblies
• Assemblies resolutionAssemblies resolution
– Using metadataUsing metadata
• Local (preferred)Local (preferred)
• Assembly Global CacheAssembly Global Cache
• Resolution uses version number, too!Resolution uses version number, too!
• Different applications may use differentDifferent applications may use different
versions of an assemblyversions of an assembly
– Easier software updatesEasier software updates
– Easier software removalEasier software removal
.NET Framework and CLR.NET Framework and CLR
CLR ApplicationsCLR Applications
.NET Framework and CLR.NET Framework and CLR
Shared AssembliesShared Assemblies
• Machine-level AssemblyMachine-level Assembly
• Stored in Global Assembly CacheStored in Global Assembly Cache
• It has Unique Identity called Strong NamesIt has Unique Identity called Strong Names
which consists of Public Key Tokenwhich consists of Public Key Token
.NET Framework and CLR.NET Framework and CLR
Side By Side ExecutionSide By Side Execution
• No more break compatibility problemsNo more break compatibility problems
• Having more than one version of anHaving more than one version of an
AssemblyAssembly
• Each application can use its own version ofEach application can use its own version of
an Assemblyan Assembly
• Versioning Number format:Versioning Number format:
<major>.<minor>.<build>.<revision><major>.<minor>.<build>.<revision>
Executing Managed IL CodeExecuting Managed IL Code
• When loaded, the runtime creates method stubsWhen loaded, the runtime creates method stubs
• When a method is called, the stub jumps toWhen a method is called, the stub jumps to
runtimeruntime
• Runtime loads IL and compiles itRuntime loads IL and compiles it
– IL is compiled into native CPU codeIL is compiled into native CPU code
• Method stub is removed and points to compiledMethod stub is removed and points to compiled
codecode
• Compiled code is executedCompiled code is executed
• In future, when method is called, it just runsIn future, when method is called, it just runs
Sample MSIL (C#)Sample MSIL (C#)
.method private hidebysig static void Main(string[] args) cil managed.method private hidebysig static void Main(string[] args) cil managed
{{
.entrypoint.entrypoint
.custom instance void [mscorlib]System.STAThreadAttribute::.ctor() = ( 01 00 00 00 ).custom instance void [mscorlib]System.STAThreadAttribute::.ctor() = ( 01 00 00 00 )
// Code size 20 (0x14)// Code size 20 (0x14)
.maxstack 2.maxstack 2
.locals init ([0] int32 i).locals init ([0] int32 i)
IL_0000: ldc.i4.0IL_0000: ldc.i4.0
IL_0001: stloc.0IL_0001: stloc.0
IL_0002: br.s IL_000eIL_0002: br.s IL_000e
IL_0004: ldloc.0IL_0004: ldloc.0
IL_0005: call void [mscorlib]System.Console::Write(int32)IL_0005: call void [mscorlib]System.Console::Write(int32)
IL_000a: ldloc.0IL_000a: ldloc.0
IL_000b: ldc.i4.1IL_000b: ldc.i4.1
IL_000c: addIL_000c: add
IL_000d: stloc.0IL_000d: stloc.0
IL_000e: ldloc.0IL_000e: ldloc.0
IL_000f: ldc.i4.s 100IL_000f: ldc.i4.s 100
IL_0011: blt.s IL_0004IL_0011: blt.s IL_0004
IL_0013: retIL_0013: ret
} // end of method Class1::Main} // end of method Class1::Main
Sample MSIL (VB.NET)Sample MSIL (VB.NET)
.method public static void Main() cil managed.method public static void Main() cil managed
{{
.entrypoint.entrypoint
.custom instance void [mscorlib]System.STAThreadAttribute::.ctor() = ( 01 00 00 00 ).custom instance void [mscorlib]System.STAThreadAttribute::.ctor() = ( 01 00 00 00 )
// Code size 22 (0x16)// Code size 22 (0x16)
.maxstack 2.maxstack 2
.locals init ([0] int32 i).locals init ([0] int32 i)
IL_0000: nopIL_0000: nop
IL_0001: ldc.i4.0IL_0001: ldc.i4.0
IL_0002: stloc.0IL_0002: stloc.0
IL_0003: ldloc.0IL_0003: ldloc.0
IL_0004: call void [mscorlib]System.Console::Write(int32)IL_0004: call void [mscorlib]System.Console::Write(int32)
IL_0009: nopIL_0009: nop
IL_000a: nopIL_000a: nop
IL_000b: ldloc.0IL_000b: ldloc.0
IL_000c: ldc.i4.1IL_000c: ldc.i4.1
IL_000d: add.ovfIL_000d: add.ovf
IL_000e: stloc.0IL_000e: stloc.0
IL_000f: ldloc.0IL_000f: ldloc.0
IL_0010: ldc.i4.s 100IL_0010: ldc.i4.s 100
IL_0012: ble.s IL_0003IL_0012: ble.s IL_0003
IL_0014: nopIL_0014: nop
IL_0015: retIL_0015: ret
} // end of method Module1::Main} // end of method Module1::Main
.NET Framework and CLR.NET Framework and CLR
Application DomainApplication Domain
• Process Isolation:Process Isolation:
• In Win32 OS Every Application processIn Win32 OS Every Application process
isolated from each otherisolated from each other
• Memory Address is process relative whichMemory Address is process relative which
means address of memory from onemeans address of memory from one
application process is useless/not availableapplication process is useless/not available
for other application processfor other application process
.NET Framework and CLR.NET Framework and CLR
Application DomainApplication Domain
• Application Domain provides such anApplication Domain provides such an
isolation for every managed applicationisolation for every managed application
which targeted .NET CLRwhich targeted .NET CLR
• Much better than Win32 Process Isolation.Much better than Win32 Process Isolation.
Can have multiple domain within oneCan have multiple domain within one
processprocess
Just in Time(JIT) CompilersJust in Time(JIT) Compilers
• Standard JITStandard JIT
– The default JITThe default JIT
– Operates a bit more slowly but performs aOperates a bit more slowly but performs a
high level of optimization.high level of optimization.
• EconoJITEconoJIT
– Very fast compilation, but produces un-Very fast compilation, but produces un-
optimized code.optimized code.
• PreJITPreJIT
– The invocation of the Standard JIT at theThe invocation of the Standard JIT at the
time that an application is installed.time that an application is installed.
C#C#
• A new language designed expressly for the .NETA new language designed expressly for the .NET
FrameworkFramework
– Syntax based on C/C++Syntax based on C/C++
• Built on the CLR, withBuilt on the CLR, with
– Support for the CTS:Support for the CTS:
• ClassesClasses
• InheritanceInheritance
• Method overloadingMethod overloading
• Much moreMuch more
• Has only a couple of small things that aren’t inHas only a couple of small things that aren’t in
VB.NETVB.NET
• Co-authored by Anders Hejlsberg and ScottCo-authored by Anders Hejlsberg and Scott
Wiltamuth.Wiltamuth.
What is C#?What is C#?
"C# is a simple, modern, object oriented,"C# is a simple, modern, object oriented,
and type-safe programming languageand type-safe programming language
derived from C and C++. C# (pronouncedderived from C and C++. C# (pronounced
'C sharp') is firmly planted in the C and C+'C sharp') is firmly planted in the C and C+
+ family tree of languages, and will+ family tree of languages, and will
immediately be familiar to C and C++immediately be familiar to C and C++
programmers. C# aims to combine theprogrammers. C# aims to combine the
high productivity of Visual Basic and thehigh productivity of Visual Basic and the
raw power of C++."raw power of C++."
The Development of C#The Development of C#
• C and UNIXC and UNIX
• C++ Modernizes CC++ Modernizes C
• C at MicrosoftC at Microsoft
• C++ at MicrosoftC++ at Microsoft
• Visual Basic’s SimplicityVisual Basic’s Simplicity
• Sun Creates JavaSun Creates Java
• Microsoft .NET and C#Microsoft .NET and C#
C#C#
C++C++
Feature richnessFeature richness
Direct access to memoryDirect access to memory
Legacy keywordsLegacy keywords
JavaJava
Class structureClass structure
Single inheritanceSingle inheritance
InterfacesInterfaces
Garbage CollectionGarbage Collection
Code safetyCode safety
ReflectionReflection
Convenience &Convenience &
Additional FeaturesAdditional Features
PropertiesProperties
IndexesIndexes
AttributesAttributes
DelegatesDelegates
ClassClass
• Classes serve as templates for creating objectsClasses serve as templates for creating objects
• Example:Example:
public class Personpublic class Person
{{
private string name;private string name;
private int age;private int age;
public void SetAge(int newAge)public void SetAge(int newAge)
{{
age = newAge;age = newAge;
}}
}}
Access ModifierAccess Modifier
• Accessibility level can be set to:Accessibility level can be set to:
– publicpublic
– privateprivate
– protectedprotected
– internalinternal
– internal protectedinternal protected
InheritanceInheritance
• Inheritance enables creation of a class that's just likeInheritance enables creation of a class that's just like
some existing class with a few minor specializationssome existing class with a few minor specializations
public class Shape {public class Shape {
//code for the base class//code for the base class
}}
public class Rectangle : Shape {public class Rectangle : Shape {
//code for the shape rectangle//code for the shape rectangle
}}
FieldField
Properties are attributes associated with objectsProperties are attributes associated with objects
public class Button: Controlpublic class Button: Control
{{
private string text;private string text;
public string Text {public string Text {
get {get {
return text;return text;
}}
set {set {
text = value;text = value;
Repaint();Repaint();
}}
}}
}}
Button b = new Button();Button b = new Button();
b.Text = "OK";b.Text = "OK";
string s = b.Text;string s = b.Text;
Static vs. InstanceStatic vs. Instance
FieldsFields
MethodsMethods
Static/SharedStatic/Shared
Only one copyOnly one copy
of the fieldof the field
existsexists
Cannot accessCannot access
any instance dataany instance data
in the classin the class
InstanceInstance
Default, each object ofDefault, each object of
that class has its ownthat class has its own
copycopy
Implicitly receives aImplicitly receives a
reference to the objectreference to the object
on which it's workingon which it's working
Static vs. Instance (Example)Static vs. Instance (Example)
class Test {class Test {
int x;int x;
static int y;static int y;
void InstanceF() {void InstanceF() {
x = 1; // Ok, same as this.x = 1x = 1; // Ok, same as this.x = 1
y = 1; // Ok, same as Test.y = 1y = 1; // Ok, same as Test.y = 1
}}
static void StaticF() {static void StaticF() {
x = 1; // Error, cannot access this.xx = 1; // Error, cannot access this.x
y = 1; // Ok, same as Test.y = 1y = 1; // Ok, same as Test.y = 1
}}
static void Main() {static void Main() {
Test t = new Test();Test t = new Test();
t.x = 1; // Okt.x = 1; // Ok
t.y = 1; // Error, cannot access static member throught.y = 1; // Error, cannot access static member through
// instance// instance
Test.x = 1; // Error, cannot access instance member throughTest.x = 1; // Error, cannot access instance member through
// type// type
Test.y = 1; // OkTest.y = 1; // Ok
}}
}}
IndexerIndexer
• Indexers are members that enables anIndexers are members that enables an
object to be indexed in the same way asobject to be indexed in the same way as
an arrayan array
Indexer (Example)Indexer (Example)
class IndexerClass {class IndexerClass {
private int[] myArray = new int[100];private int[] myArray = new int[100];
public int this[int index] // indexer declarationpublic int this[int index] // indexer declaration
{{
get { /* code for the get accessor */ }get { /* code for the get accessor */ }
set { /* code for the get accessor */ }set { /* code for the get accessor */ }
}}
}}
public class MainClass {public class MainClass {
public static void Main() {public static void Main() {
IndexerClass b = new IndexerClass();IndexerClass b = new IndexerClass();
b[3] = 256;b[3] = 256;
b[5] = 1024;b[5] = 1024;
for (int i=0; i<=10; i++)for (int i=0; i<=10; i++)
Console.WriteLine("Element #{0} = {1}", i, b[i]);Console.WriteLine("Element #{0} = {1}", i, b[i]);
}}
}}
DelegateDelegate
• Delegates are objects that contain aDelegates are objects that contain a
reference to a methodreference to a method
– If the method is an instance method to aIf the method is an instance method to a
particular objectparticular object
• Delegate type contains a signatureDelegate type contains a signature
– Which must match method to be calledWhich must match method to be called
Delegate (Example)Delegate (Example)
// delegate declaration// delegate declaration
delegate void SimpleDelegate();delegate void SimpleDelegate();
// delegate instantiation and invocation// delegate instantiation and invocation
class Test {class Test {
static void F() {static void F() {
System.Console.WriteLine("Test.F");System.Console.WriteLine("Test.F");
}}
static void Main() {static void Main() {
SimpleDelegate d = new SimpleDelegate(F);SimpleDelegate d = new SimpleDelegate(F);
d();d();
}}
}}
EventEvent
public delegate void EventHandler(public delegate void EventHandler(
object sender, EventArgs e);object sender, EventArgs e);
public class Button: Controlpublic class Button: Control
{{
public event EventHandler Click;public event EventHandler Click;
protected void OnClick(EventArgs e) {protected void OnClick(EventArgs e) {
if (Click != null) Click(this, e);if (Click != null) Click(this, e);
}}
}}
void Initialize() {void Initialize() {
Button b = new Button(...);Button b = new Button(...);
b.Click += new EventHandler(ButtonClick);b.Click += new EventHandler(ButtonClick);
}}
void ButtonClick(object sender, EventArgs e) {void ButtonClick(object sender, EventArgs e) {
MessageBox.Show("You pressed the button");MessageBox.Show("You pressed the button");
}}
AttributeAttribute
• How do you associate information withHow do you associate information with
types and members?types and members?
– Category of a propertyCategory of a property
– Transaction context for a methodTransaction context for a method
– XML persistence mappingXML persistence mapping
• Traditional solutionsTraditional solutions
– Add keywords or pragmas to languageAdd keywords or pragmas to language
– Use external files (e.g., .IDL, .DEF)Use external files (e.g., .IDL, .DEF)
• C# solution: AttributesC# solution: Attributes
Attribute (Example)Attribute (Example)
[Serializable][Serializable]
public class Testpublic class Test
{{
public Test()public Test()
{{
}}
[Obsolete("Bug!")][Obsolete("Bug!")]
public void Do()public void Do()
{{
// actions// actions
}}
}}
DemoDemo

More Related Content

What's hot

Type script - advanced usage and practices
Type script  - advanced usage and practicesType script  - advanced usage and practices
Type script - advanced usage and practicesIwan van der Kleijn
 
TypeScript: Basic Features and Compilation Guide
TypeScript: Basic Features and Compilation GuideTypeScript: Basic Features and Compilation Guide
TypeScript: Basic Features and Compilation GuideNascenia IT
 
Common language runtime clr
Common language runtime clrCommon language runtime clr
Common language runtime clrSanSan149
 
DotNet Introduction
DotNet IntroductionDotNet Introduction
DotNet IntroductionWei Sun
 
Evolution of .net frame work
Evolution of .net frame workEvolution of .net frame work
Evolution of .net frame workvc7722
 
.NET Framework Overview
.NET Framework Overview.NET Framework Overview
.NET Framework OverviewDoncho Minkov
 
Typescript: enjoying large scale browser development
Typescript: enjoying large scale browser developmentTypescript: enjoying large scale browser development
Typescript: enjoying large scale browser developmentJoost de Vries
 
2.Getting Started with C#.Net-(C#)
2.Getting Started with C#.Net-(C#)2.Getting Started with C#.Net-(C#)
2.Getting Started with C#.Net-(C#)Shoaib Ghachi
 
Rootcon X - Reverse Engineering Swift Applications
Rootcon X - Reverse Engineering Swift ApplicationsRootcon X - Reverse Engineering Swift Applications
Rootcon X - Reverse Engineering Swift Applicationseightbit
 
1..Net Framework Architecture-(c#)
1..Net Framework Architecture-(c#)1..Net Framework Architecture-(c#)
1..Net Framework Architecture-(c#)Shoaib Ghachi
 
.Net framework components by naveen kumar veligeti
.Net framework components by naveen kumar veligeti.Net framework components by naveen kumar veligeti
.Net framework components by naveen kumar veligetiNaveen Kumar Veligeti
 
Wahckon[2] - iOS Runtime Hacking Crash Course
Wahckon[2] - iOS Runtime Hacking Crash CourseWahckon[2] - iOS Runtime Hacking Crash Course
Wahckon[2] - iOS Runtime Hacking Crash Courseeightbit
 
Visual Studio 2010 and .NET Framework 4.0 Overview
Visual Studio 2010 and .NET Framework 4.0 OverviewVisual Studio 2010 and .NET Framework 4.0 Overview
Visual Studio 2010 and .NET Framework 4.0 OverviewHarish Ranganathan
 
Introduction to .net FrameWork by QuontraSolutions
Introduction to .net FrameWork by QuontraSolutionsIntroduction to .net FrameWork by QuontraSolutions
Introduction to .net FrameWork by QuontraSolutionsQuontra Solutions
 
Introduction .NET Framework
Introduction .NET FrameworkIntroduction .NET Framework
Introduction .NET Frameworkjavadib
 
TypeScript: coding JavaScript without the pain
TypeScript: coding JavaScript without the painTypeScript: coding JavaScript without the pain
TypeScript: coding JavaScript without the painSander Mak (@Sander_Mak)
 

What's hot (20)

Type script - advanced usage and practices
Type script  - advanced usage and practicesType script  - advanced usage and practices
Type script - advanced usage and practices
 
.Net framework
.Net framework.Net framework
.Net framework
 
TypeScript: Basic Features and Compilation Guide
TypeScript: Basic Features and Compilation GuideTypeScript: Basic Features and Compilation Guide
TypeScript: Basic Features and Compilation Guide
 
Common language runtime clr
Common language runtime clrCommon language runtime clr
Common language runtime clr
 
AngularConf2015
AngularConf2015AngularConf2015
AngularConf2015
 
DotNet Introduction
DotNet IntroductionDotNet Introduction
DotNet Introduction
 
Evolution of .net frame work
Evolution of .net frame workEvolution of .net frame work
Evolution of .net frame work
 
.NET Framework Overview
.NET Framework Overview.NET Framework Overview
.NET Framework Overview
 
Typescript ppt
Typescript pptTypescript ppt
Typescript ppt
 
Typescript: enjoying large scale browser development
Typescript: enjoying large scale browser developmentTypescript: enjoying large scale browser development
Typescript: enjoying large scale browser development
 
2.Getting Started with C#.Net-(C#)
2.Getting Started with C#.Net-(C#)2.Getting Started with C#.Net-(C#)
2.Getting Started with C#.Net-(C#)
 
Rootcon X - Reverse Engineering Swift Applications
Rootcon X - Reverse Engineering Swift ApplicationsRootcon X - Reverse Engineering Swift Applications
Rootcon X - Reverse Engineering Swift Applications
 
1..Net Framework Architecture-(c#)
1..Net Framework Architecture-(c#)1..Net Framework Architecture-(c#)
1..Net Framework Architecture-(c#)
 
.Net framework components by naveen kumar veligeti
.Net framework components by naveen kumar veligeti.Net framework components by naveen kumar veligeti
.Net framework components by naveen kumar veligeti
 
Wahckon[2] - iOS Runtime Hacking Crash Course
Wahckon[2] - iOS Runtime Hacking Crash CourseWahckon[2] - iOS Runtime Hacking Crash Course
Wahckon[2] - iOS Runtime Hacking Crash Course
 
Microsoft .NET Framework
Microsoft .NET FrameworkMicrosoft .NET Framework
Microsoft .NET Framework
 
Visual Studio 2010 and .NET Framework 4.0 Overview
Visual Studio 2010 and .NET Framework 4.0 OverviewVisual Studio 2010 and .NET Framework 4.0 Overview
Visual Studio 2010 and .NET Framework 4.0 Overview
 
Introduction to .net FrameWork by QuontraSolutions
Introduction to .net FrameWork by QuontraSolutionsIntroduction to .net FrameWork by QuontraSolutions
Introduction to .net FrameWork by QuontraSolutions
 
Introduction .NET Framework
Introduction .NET FrameworkIntroduction .NET Framework
Introduction .NET Framework
 
TypeScript: coding JavaScript without the pain
TypeScript: coding JavaScript without the painTypeScript: coding JavaScript without the pain
TypeScript: coding JavaScript without the pain
 

Similar to NET Framework Introduction

Similar to NET Framework Introduction (20)

.Net programming with C#
.Net programming with C#.Net programming with C#
.Net programming with C#
 
Intro to .NET and Core C#
Intro to .NET and Core C#Intro to .NET and Core C#
Intro to .NET and Core C#
 
Microsoft .NET (dotnet) Framework 2003 - 2004 overview and web services…
Microsoft .NET (dotnet) Framework 2003 - 2004 overview and web services…Microsoft .NET (dotnet) Framework 2003 - 2004 overview and web services…
Microsoft .NET (dotnet) Framework 2003 - 2004 overview and web services…
 
.Net overview
.Net overview.Net overview
.Net overview
 
Introduction to .NET Framework
Introduction to .NET FrameworkIntroduction to .NET Framework
Introduction to .NET Framework
 
Modified.net overview
Modified.net overviewModified.net overview
Modified.net overview
 
Net Framework overview
Net Framework overviewNet Framework overview
Net Framework overview
 
Presentation1.pptx
Presentation1.pptxPresentation1.pptx
Presentation1.pptx
 
Net overview
Net overviewNet overview
Net overview
 
DOT Net overview
DOT Net overviewDOT Net overview
DOT Net overview
 
Net overview
Net overviewNet overview
Net overview
 
.Net overview|Introduction Of .net
.Net overview|Introduction Of .net.Net overview|Introduction Of .net
.Net overview|Introduction Of .net
 
.Net overview by cetpa
.Net overview by cetpa.Net overview by cetpa
.Net overview by cetpa
 
.Net framework
.Net framework.Net framework
.Net framework
 
Introduction to c_sharp
Introduction to c_sharpIntroduction to c_sharp
Introduction to c_sharp
 
Introduction to c_sharp
Introduction to c_sharpIntroduction to c_sharp
Introduction to c_sharp
 
.Net framework
.Net framework.Net framework
.Net framework
 
CS4443 - Modern Programming Language - I Lecture (1)
CS4443 - Modern Programming Language - I Lecture (1)CS4443 - Modern Programming Language - I Lecture (1)
CS4443 - Modern Programming Language - I Lecture (1)
 
Microsoft dot net framework
Microsoft dot net frameworkMicrosoft dot net framework
Microsoft dot net framework
 
PROGRAMMING USING C#.NET SARASWATHI RAMALINGAM
PROGRAMMING USING C#.NET SARASWATHI RAMALINGAMPROGRAMMING USING C#.NET SARASWATHI RAMALINGAM
PROGRAMMING USING C#.NET SARASWATHI RAMALINGAM
 

More from Joni

ASP.NET Core の ​ パフォーマンスを支える ​ I/O Pipeline と Channel
ASP.NET Core の ​ パフォーマンスを支える ​ I/O Pipeline と ChannelASP.NET Core の ​ パフォーマンスを支える ​ I/O Pipeline と Channel
ASP.NET Core の ​ パフォーマンスを支える ​ I/O Pipeline と ChannelJoni
 
.NET Framework で ​C# 8って使える? ​YESとNO!
.NET Framework で ​C# 8って使える? ​YESとNO!.NET Framework で ​C# 8って使える? ​YESとNO!
.NET Framework で ​C# 8って使える? ​YESとNO!Joni
 
.NET Core 3.0 で Blazor を使用した​フルスタック C# Web アプリ​の構築
.NET Core 3.0 で Blazor を使用した​フルスタック C# Web アプリ​の構築.NET Core 3.0 で Blazor を使用した​フルスタック C# Web アプリ​の構築
.NET Core 3.0 で Blazor を使用した​フルスタック C# Web アプリ​の構築Joni
 
Fiddler 使ってますか?
Fiddler 使ってますか?Fiddler 使ってますか?
Fiddler 使ってますか?Joni
 
Fukuoka.NET Conf 2018: 挑み続ける!Dockerコンテナによる ASP.NET Core アプリケーション開発事例
Fukuoka.NET Conf 2018: 挑み続ける!Dockerコンテナによる ASP.NET Core アプリケーション開発事例Fukuoka.NET Conf 2018: 挑み続ける!Dockerコンテナによる ASP.NET Core アプリケーション開発事例
Fukuoka.NET Conf 2018: 挑み続ける!Dockerコンテナによる ASP.NET Core アプリケーション開発事例Joni
 
ASP.NET パフォーマンス改善
ASP.NET パフォーマンス改善ASP.NET パフォーマンス改善
ASP.NET パフォーマンス改善Joni
 
Tips and Tricks of Developing .NET Application
Tips and Tricks of Developing .NET ApplicationTips and Tricks of Developing .NET Application
Tips and Tricks of Developing .NET ApplicationJoni
 
Introduction to Html
Introduction to HtmlIntroduction to Html
Introduction to HtmlJoni
 
Asp #1
Asp #1Asp #1
Asp #1Joni
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NETJoni
 
Asp #2
Asp #2Asp #2
Asp #2Joni
 
ASP.NET MVCはNullReferenceExceptionを潰している件
ASP.NET MVCはNullReferenceExceptionを潰している件ASP.NET MVCはNullReferenceExceptionを潰している件
ASP.NET MVCはNullReferenceExceptionを潰している件Joni
 

More from Joni (13)

ASP.NET Core の ​ パフォーマンスを支える ​ I/O Pipeline と Channel
ASP.NET Core の ​ パフォーマンスを支える ​ I/O Pipeline と ChannelASP.NET Core の ​ パフォーマンスを支える ​ I/O Pipeline と Channel
ASP.NET Core の ​ パフォーマンスを支える ​ I/O Pipeline と Channel
 
.NET Framework で ​C# 8って使える? ​YESとNO!
.NET Framework で ​C# 8って使える? ​YESとNO!.NET Framework で ​C# 8って使える? ​YESとNO!
.NET Framework で ​C# 8って使える? ​YESとNO!
 
.NET Core 3.0 で Blazor を使用した​フルスタック C# Web アプリ​の構築
.NET Core 3.0 で Blazor を使用した​フルスタック C# Web アプリ​の構築.NET Core 3.0 で Blazor を使用した​フルスタック C# Web アプリ​の構築
.NET Core 3.0 で Blazor を使用した​フルスタック C# Web アプリ​の構築
 
Fiddler 使ってますか?
Fiddler 使ってますか?Fiddler 使ってますか?
Fiddler 使ってますか?
 
Fukuoka.NET Conf 2018: 挑み続ける!Dockerコンテナによる ASP.NET Core アプリケーション開発事例
Fukuoka.NET Conf 2018: 挑み続ける!Dockerコンテナによる ASP.NET Core アプリケーション開発事例Fukuoka.NET Conf 2018: 挑み続ける!Dockerコンテナによる ASP.NET Core アプリケーション開発事例
Fukuoka.NET Conf 2018: 挑み続ける!Dockerコンテナによる ASP.NET Core アプリケーション開発事例
 
ASP.NET パフォーマンス改善
ASP.NET パフォーマンス改善ASP.NET パフォーマンス改善
ASP.NET パフォーマンス改善
 
Tips and Tricks of Developing .NET Application
Tips and Tricks of Developing .NET ApplicationTips and Tricks of Developing .NET Application
Tips and Tricks of Developing .NET Application
 
Introduction to Html
Introduction to HtmlIntroduction to Html
Introduction to Html
 
C#
C#C#
C#
 
Asp #1
Asp #1Asp #1
Asp #1
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NET
 
Asp #2
Asp #2Asp #2
Asp #2
 
ASP.NET MVCはNullReferenceExceptionを潰している件
ASP.NET MVCはNullReferenceExceptionを潰している件ASP.NET MVCはNullReferenceExceptionを潰している件
ASP.NET MVCはNullReferenceExceptionを潰している件
 

Recently uploaded

What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 

Recently uploaded (20)

What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 

NET Framework Introduction

  • 1. Introduction to .NETIntroduction to .NET JoniJoni ATL - Bina NusantaraATL - Bina Nusantara
  • 2. Session PrerequisitesSession Prerequisites • This session assumes that you familiarThis session assumes that you familiar with:with: – Component-Based or Object-OrientedComponent-Based or Object-Oriented DevelopmentDevelopment – Java, Visual C++ or Visual BasicJava, Visual C++ or Visual Basic programming languageprogramming language
  • 3. AgendaAgenda • .NET Framework.NET Framework – GoalsGoals – .NET Platform.NET Platform – .NET Compact Framework.NET Compact Framework • C#C# – What is C#What is C# – The Development of C#The Development of C#
  • 4. .NET Framework.NET Framework GoalsGoals • DevelopmentDevelopment – First-class support for componentsFirst-class support for components – Standard class frameworkStandard class framework – Automatic memory managementAutomatic memory management – Consistent error handlingConsistent error handling – Mixed language applicationsMixed language applications – Multiple platformsMultiple platforms – Safer executionSafer execution • DeploymentDeployment – Removal on registration dependencyRemoval on registration dependency – Safety – fewer versioning problemsSafety – fewer versioning problems – The end of ‘DLL Hell’The end of ‘DLL Hell’
  • 5. .NET Platform.NET Platform •.NET experiences are XML Web.NET experiences are XML Web services that allow you to accessservices that allow you to access information across the Internet andinformation across the Internet and from standalone applications in anfrom standalone applications in an integrated way.integrated way. •Some of the products that MicrosoftSome of the products that Microsoft is transitioning into .NETis transitioning into .NET experiences are MSN, bCentral,experiences are MSN, bCentral, PassportPassport •Clients are all smart devices such as PCs, laptops, workstations, phones, handheld computers •Some of the .NET client software Microsoft will offer are Windows CE, Windows Embedded, Window 2000, Windows XP, Windows Server 2003 •A core set of building block services that perform routine tasks and act as the backbone for developers to build upon. •.NET My Services(HailStorm) •Microsoft Windows Server 2003 •Microsoft Application Center 2000 •Microsoft BizTalk™ Server 2000 •Microsoft Commerce Server 2000 •Microsoft Content Management Server 2001 •Microsoft Exchange Server 2000 •Microsoft Host Integration Server 2000 •Microsoft Internet Security and Acceleration Server 2000 •Microsoft Mobile Information 2001 Server •Microsoft SharePoint™ Portal Server 2001 •Microsoft SQL Server™ 2000 •The Microsoft .NET Framework SDK •Microsoft Visual Studio.NET 2002 •Microsoft Visual Studio.NET 2003
  • 6. The .NET FrameworkThe .NET Framework Operating SystemOperating System Common Language RuntimeCommon Language Runtime Base Class LibraryBase Class Library ADO.NET and XMLADO.NET and XML ASP.NETASP.NET Web Forms, Web Services,Web Forms, Web Services, Mobile Web ApplicationMobile Web Application WindowsWindows FormsForms Common Language SpecificationCommon Language Specification VBVB C++C++ C#C# JScriptJScript …… VisualStudio.NETVisualStudio.NET
  • 7. .NET Framework and CLR.NET Framework and CLR CLR Execution ModelCLR Execution Model VBVBSourceSource codecode CompilerCompiler C++C++C#C# CompilerCompilerCompilerCompiler AssemblyAssembly IL CodeIL Code AssemblyAssembly IL CodeIL Code AssemblyAssembly IL CodeIL Code Operating System ServicesOperating System Services Common Language RuntimeCommon Language Runtime JIT CompilerJIT Compiler Native CodeNative Code ManagedManaged codecode UnmanagedUnmanaged ComponentComponent
  • 8. The .NET Compact FrameworkThe .NET Compact Framework • .NET will also be available on devices.NET will also be available on devices – Cell phones, PDAs, others...Cell phones, PDAs, others... • .NET Compact Framework will be....NET Compact Framework will be... – FamiliarFamiliar – Modular—only use pieces you needModular—only use pieces you need – ExtensibleExtensible – Cross-processorCross-processor – Run on multiple OSesRun on multiple OSes • Not just Windows CENot just Windows CE
  • 9. The .NET Framework Class LibraryThe .NET Framework Class Library • Accessible from any language targeting the CLRAccessible from any language targeting the CLR • Written in C#Written in C# • Organized into namespacesOrganized into namespaces – All of which are below the System namespaceAll of which are below the System namespace • Contains:Contains: – ASP.NETASP.NET – ADO.NETADO.NET – Windows FormsWindows Forms – Much, much moreMuch, much more
  • 10. Common Type SystemCommon Type System • Every languages that is CLS complianceEvery languages that is CLS compliance use the same type that use through all theuse the same type that use through all the frameworkframework • This Type which is targeted by .NETThis Type which is targeted by .NET compilers called Common Type Systemcompilers called Common Type System • This makes sure that every type isThis makes sure that every type is supported cross-language developmentsupported cross-language development
  • 11. Unified Type SystemUnified Type System • Traditional views of primitive typesTraditional views of primitive types – C++, Java: They’re “magic”C++, Java: They’re “magic” – Smalltalk, Lisp: They’re full-blown objectsSmalltalk, Lisp: They’re full-blown objects • C# unifies with no performance costC# unifies with no performance cost – Value types, boxing and unboxingValue types, boxing and unboxing – Deep simplicity throughout systemDeep simplicity throughout system • Improved extensibility and reusabilityImproved extensibility and reusability – New primitive types: Decimal, SQL…New primitive types: Decimal, SQL… – Collections, etc., work for all typesCollections, etc., work for all types
  • 12. Illustrating the CTSIllustrating the CTS Object ValueType Boolean Byte Char Decimal Double Int16 Int32 Single Int64 UInt16 UInt32 UInt64 Class String Array Interface Delegate Value Types Enum Structure Others Others
  • 13. Value and Reference TypesValue and Reference Types • Value typesValue types – Variables directly contain dataVariables directly contain data – Cannot be nullCannot be null • Reference typesReference types – Variables contain references to objectsVariables contain references to objects – May be nullMay be null int i = 123;int i = 123; string s = "Hello world";string s = "Hello world";123123ii ss "Hello world""Hello world"
  • 14. Common Type SystemCommon Type System • Conversion between each type:Conversion between each type: Boxing ConversionBoxing Conversion Convert Value Type to Reference TypeConvert Value Type to Reference Type .NET creates appropriate dynamic type.NET creates appropriate dynamic type to “box” the value type.to “box” the value type. int i = 100;int i = 100; object o = i;object o = i;
  • 15. Common Type SystemCommon Type System • Conversion between each type:Conversion between each type: UnBoxing ConversionUnBoxing Conversion Convert Reference Type to Value TypeConvert Reference Type to Value Type int i = (int) o;int i = (int) o;
  • 16. Common Language SpecificationCommon Language Specification • Microsoft’s CLS describes minimum setMicrosoft’s CLS describes minimum set of features that a CLR-compliantof features that a CLR-compliant compiler must supportcompiler must support • Note: the CLR supports more featuresNote: the CLR supports more features than the CLS describesthan the CLS describes – Using these features prevents inter-Using these features prevents inter- language operabilitylanguage operability
  • 17. .NET Framework and CLR.NET Framework and CLR Garbage CollectionGarbage Collection  Garbage collection is the process ofGarbage collection is the process of automatically freeing up memory when anautomatically freeing up memory when an object it been allocated to is no longerobject it been allocated to is no longer being usedbeing used
  • 18. .NET Framework and CLR.NET Framework and CLR Benefits of Garbage CollectionBenefits of Garbage Collection  Garbage collection prevents the followingGarbage collection prevents the following errors:errors:  Forgetting to destroy objectsForgetting to destroy objects  Attempting to destroy the same object moreAttempting to destroy the same object more than oncethan once  Destroying an active objectDestroying an active object
  • 19. myAssembly.DLLmyAssembly.DLL .NET Framework and CLR.NET Framework and CLR AssembliesAssemblies myAssembly.DLLmyAssembly.DLL Single ModuleSingle Module Multiple ModulesMultiple Modules ManifestManifestManifestManifest MetadataMetadataMetadataMetadata IL CodeIL CodeIL CodeIL Code Util.netmoduleUtil.netmodule MetadataMetadataMetadataMetadata IL CodeIL CodeIL CodeIL Code Graphic.BMPGraphic.BMP ResourcesResourcesResourcesResources MetadataMetadataMetadataMetadata IL codeIL codeIL codeIL code ResourcesResourcesResourcesResources ManifestManifestManifestManifest
  • 20. .NET Framework and CLR.NET Framework and CLR AssembliesAssemblies • Advantages of Assemblies:Advantages of Assemblies: – Self-DescribingSelf-Describing – Side by Side executionSide by Side execution – Ease of Deployment (avoid DLL-Hell)Ease of Deployment (avoid DLL-Hell) – Ease of uninstallationEase of uninstallation
  • 21. .NET Framework and CLR.NET Framework and CLR AssembliesAssemblies • Structure of an Assembly:Structure of an Assembly: – ManifestManifest – Type MetaDataType MetaData – MSIL CodeMSIL Code – Resources (optional)Resources (optional)
  • 22. .NET Framework and CLR.NET Framework and CLR ManifestManifest • Data Structures stores details ofData Structures stores details of an Assembly:an Assembly: – Assembly Name and versionAssembly Name and version – OS and Processor used to built toOS and Processor used to built to – List of Dependencies filesList of Dependencies files – Strong Name InformationStrong Name Information
  • 23. .NET Framework and CLR.NET Framework and CLR MetadataMetadata • Type InformationType Information – More complete than IDL / TLBMore complete than IDL / TLB – Automatically bound into assemblyAutomatically bound into assembly • InseparableInseparable • Stored in binary formatStored in binary format – Describes every class typeDescribes every class type – Used by VS.NET IntelliSenseUsed by VS.NET IntelliSense™™ , compilers,, compilers, runtime, etc.runtime, etc.
  • 24. .NET Framework and CLR.NET Framework and CLR AssembliesAssemblies • Two kind of Assemblies:Two kind of Assemblies: – Static AssembliesStatic Assemblies • Persisted in diskPersisted in disk • Most usedMost used – Dynamic AssembliesDynamic Assemblies • Build on the fly using Reflection APIBuild on the fly using Reflection API • Exists in MemoryExists in Memory • Can be converted to Static AssembliesCan be converted to Static Assemblies • Less usedLess used
  • 25. .NET Framework and CLR.NET Framework and CLR AssembliesAssemblies • Types of Static AssembliesTypes of Static Assemblies – Single File AssembliesSingle File Assemblies Using only one file to store all parts of anUsing only one file to store all parts of an Assembly (Manifest, Metadata, IL, Res)Assembly (Manifest, Metadata, IL, Res) – Multi File AssembliesMulti File Assemblies Implementation of an Assembly split overImplementation of an Assembly split over several files. Every part called .NET module.several files. Every part called .NET module.
  • 26. • Using One or more assembliesUsing One or more assemblies • Assemblies resolutionAssemblies resolution – Using metadataUsing metadata • Local (preferred)Local (preferred) • Assembly Global CacheAssembly Global Cache • Resolution uses version number, too!Resolution uses version number, too! • Different applications may use differentDifferent applications may use different versions of an assemblyversions of an assembly – Easier software updatesEasier software updates – Easier software removalEasier software removal .NET Framework and CLR.NET Framework and CLR CLR ApplicationsCLR Applications
  • 27. .NET Framework and CLR.NET Framework and CLR Shared AssembliesShared Assemblies • Machine-level AssemblyMachine-level Assembly • Stored in Global Assembly CacheStored in Global Assembly Cache • It has Unique Identity called Strong NamesIt has Unique Identity called Strong Names which consists of Public Key Tokenwhich consists of Public Key Token
  • 28. .NET Framework and CLR.NET Framework and CLR Side By Side ExecutionSide By Side Execution • No more break compatibility problemsNo more break compatibility problems • Having more than one version of anHaving more than one version of an AssemblyAssembly • Each application can use its own version ofEach application can use its own version of an Assemblyan Assembly • Versioning Number format:Versioning Number format: <major>.<minor>.<build>.<revision><major>.<minor>.<build>.<revision>
  • 29. Executing Managed IL CodeExecuting Managed IL Code • When loaded, the runtime creates method stubsWhen loaded, the runtime creates method stubs • When a method is called, the stub jumps toWhen a method is called, the stub jumps to runtimeruntime • Runtime loads IL and compiles itRuntime loads IL and compiles it – IL is compiled into native CPU codeIL is compiled into native CPU code • Method stub is removed and points to compiledMethod stub is removed and points to compiled codecode • Compiled code is executedCompiled code is executed • In future, when method is called, it just runsIn future, when method is called, it just runs
  • 30. Sample MSIL (C#)Sample MSIL (C#) .method private hidebysig static void Main(string[] args) cil managed.method private hidebysig static void Main(string[] args) cil managed {{ .entrypoint.entrypoint .custom instance void [mscorlib]System.STAThreadAttribute::.ctor() = ( 01 00 00 00 ).custom instance void [mscorlib]System.STAThreadAttribute::.ctor() = ( 01 00 00 00 ) // Code size 20 (0x14)// Code size 20 (0x14) .maxstack 2.maxstack 2 .locals init ([0] int32 i).locals init ([0] int32 i) IL_0000: ldc.i4.0IL_0000: ldc.i4.0 IL_0001: stloc.0IL_0001: stloc.0 IL_0002: br.s IL_000eIL_0002: br.s IL_000e IL_0004: ldloc.0IL_0004: ldloc.0 IL_0005: call void [mscorlib]System.Console::Write(int32)IL_0005: call void [mscorlib]System.Console::Write(int32) IL_000a: ldloc.0IL_000a: ldloc.0 IL_000b: ldc.i4.1IL_000b: ldc.i4.1 IL_000c: addIL_000c: add IL_000d: stloc.0IL_000d: stloc.0 IL_000e: ldloc.0IL_000e: ldloc.0 IL_000f: ldc.i4.s 100IL_000f: ldc.i4.s 100 IL_0011: blt.s IL_0004IL_0011: blt.s IL_0004 IL_0013: retIL_0013: ret } // end of method Class1::Main} // end of method Class1::Main
  • 31. Sample MSIL (VB.NET)Sample MSIL (VB.NET) .method public static void Main() cil managed.method public static void Main() cil managed {{ .entrypoint.entrypoint .custom instance void [mscorlib]System.STAThreadAttribute::.ctor() = ( 01 00 00 00 ).custom instance void [mscorlib]System.STAThreadAttribute::.ctor() = ( 01 00 00 00 ) // Code size 22 (0x16)// Code size 22 (0x16) .maxstack 2.maxstack 2 .locals init ([0] int32 i).locals init ([0] int32 i) IL_0000: nopIL_0000: nop IL_0001: ldc.i4.0IL_0001: ldc.i4.0 IL_0002: stloc.0IL_0002: stloc.0 IL_0003: ldloc.0IL_0003: ldloc.0 IL_0004: call void [mscorlib]System.Console::Write(int32)IL_0004: call void [mscorlib]System.Console::Write(int32) IL_0009: nopIL_0009: nop IL_000a: nopIL_000a: nop IL_000b: ldloc.0IL_000b: ldloc.0 IL_000c: ldc.i4.1IL_000c: ldc.i4.1 IL_000d: add.ovfIL_000d: add.ovf IL_000e: stloc.0IL_000e: stloc.0 IL_000f: ldloc.0IL_000f: ldloc.0 IL_0010: ldc.i4.s 100IL_0010: ldc.i4.s 100 IL_0012: ble.s IL_0003IL_0012: ble.s IL_0003 IL_0014: nopIL_0014: nop IL_0015: retIL_0015: ret } // end of method Module1::Main} // end of method Module1::Main
  • 32. .NET Framework and CLR.NET Framework and CLR Application DomainApplication Domain • Process Isolation:Process Isolation: • In Win32 OS Every Application processIn Win32 OS Every Application process isolated from each otherisolated from each other • Memory Address is process relative whichMemory Address is process relative which means address of memory from onemeans address of memory from one application process is useless/not availableapplication process is useless/not available for other application processfor other application process
  • 33. .NET Framework and CLR.NET Framework and CLR Application DomainApplication Domain • Application Domain provides such anApplication Domain provides such an isolation for every managed applicationisolation for every managed application which targeted .NET CLRwhich targeted .NET CLR • Much better than Win32 Process Isolation.Much better than Win32 Process Isolation. Can have multiple domain within oneCan have multiple domain within one processprocess
  • 34. Just in Time(JIT) CompilersJust in Time(JIT) Compilers • Standard JITStandard JIT – The default JITThe default JIT – Operates a bit more slowly but performs aOperates a bit more slowly but performs a high level of optimization.high level of optimization. • EconoJITEconoJIT – Very fast compilation, but produces un-Very fast compilation, but produces un- optimized code.optimized code. • PreJITPreJIT – The invocation of the Standard JIT at theThe invocation of the Standard JIT at the time that an application is installed.time that an application is installed.
  • 35. C#C# • A new language designed expressly for the .NETA new language designed expressly for the .NET FrameworkFramework – Syntax based on C/C++Syntax based on C/C++ • Built on the CLR, withBuilt on the CLR, with – Support for the CTS:Support for the CTS: • ClassesClasses • InheritanceInheritance • Method overloadingMethod overloading • Much moreMuch more • Has only a couple of small things that aren’t inHas only a couple of small things that aren’t in VB.NETVB.NET • Co-authored by Anders Hejlsberg and ScottCo-authored by Anders Hejlsberg and Scott Wiltamuth.Wiltamuth.
  • 36. What is C#?What is C#? "C# is a simple, modern, object oriented,"C# is a simple, modern, object oriented, and type-safe programming languageand type-safe programming language derived from C and C++. C# (pronouncedderived from C and C++. C# (pronounced 'C sharp') is firmly planted in the C and C+'C sharp') is firmly planted in the C and C+ + family tree of languages, and will+ family tree of languages, and will immediately be familiar to C and C++immediately be familiar to C and C++ programmers. C# aims to combine theprogrammers. C# aims to combine the high productivity of Visual Basic and thehigh productivity of Visual Basic and the raw power of C++."raw power of C++."
  • 37. The Development of C#The Development of C# • C and UNIXC and UNIX • C++ Modernizes CC++ Modernizes C • C at MicrosoftC at Microsoft • C++ at MicrosoftC++ at Microsoft • Visual Basic’s SimplicityVisual Basic’s Simplicity • Sun Creates JavaSun Creates Java • Microsoft .NET and C#Microsoft .NET and C#
  • 38. C#C# C++C++ Feature richnessFeature richness Direct access to memoryDirect access to memory Legacy keywordsLegacy keywords JavaJava Class structureClass structure Single inheritanceSingle inheritance InterfacesInterfaces Garbage CollectionGarbage Collection Code safetyCode safety ReflectionReflection Convenience &Convenience & Additional FeaturesAdditional Features PropertiesProperties IndexesIndexes AttributesAttributes DelegatesDelegates
  • 39. ClassClass • Classes serve as templates for creating objectsClasses serve as templates for creating objects • Example:Example: public class Personpublic class Person {{ private string name;private string name; private int age;private int age; public void SetAge(int newAge)public void SetAge(int newAge) {{ age = newAge;age = newAge; }} }}
  • 40. Access ModifierAccess Modifier • Accessibility level can be set to:Accessibility level can be set to: – publicpublic – privateprivate – protectedprotected – internalinternal – internal protectedinternal protected
  • 41. InheritanceInheritance • Inheritance enables creation of a class that's just likeInheritance enables creation of a class that's just like some existing class with a few minor specializationssome existing class with a few minor specializations public class Shape {public class Shape { //code for the base class//code for the base class }} public class Rectangle : Shape {public class Rectangle : Shape { //code for the shape rectangle//code for the shape rectangle }}
  • 42. FieldField Properties are attributes associated with objectsProperties are attributes associated with objects public class Button: Controlpublic class Button: Control {{ private string text;private string text; public string Text {public string Text { get {get { return text;return text; }} set {set { text = value;text = value; Repaint();Repaint(); }} }} }} Button b = new Button();Button b = new Button(); b.Text = "OK";b.Text = "OK"; string s = b.Text;string s = b.Text;
  • 43. Static vs. InstanceStatic vs. Instance FieldsFields MethodsMethods Static/SharedStatic/Shared Only one copyOnly one copy of the fieldof the field existsexists Cannot accessCannot access any instance dataany instance data in the classin the class InstanceInstance Default, each object ofDefault, each object of that class has its ownthat class has its own copycopy Implicitly receives aImplicitly receives a reference to the objectreference to the object on which it's workingon which it's working
  • 44. Static vs. Instance (Example)Static vs. Instance (Example) class Test {class Test { int x;int x; static int y;static int y; void InstanceF() {void InstanceF() { x = 1; // Ok, same as this.x = 1x = 1; // Ok, same as this.x = 1 y = 1; // Ok, same as Test.y = 1y = 1; // Ok, same as Test.y = 1 }} static void StaticF() {static void StaticF() { x = 1; // Error, cannot access this.xx = 1; // Error, cannot access this.x y = 1; // Ok, same as Test.y = 1y = 1; // Ok, same as Test.y = 1 }} static void Main() {static void Main() { Test t = new Test();Test t = new Test(); t.x = 1; // Okt.x = 1; // Ok t.y = 1; // Error, cannot access static member throught.y = 1; // Error, cannot access static member through // instance// instance Test.x = 1; // Error, cannot access instance member throughTest.x = 1; // Error, cannot access instance member through // type// type Test.y = 1; // OkTest.y = 1; // Ok }} }}
  • 45. IndexerIndexer • Indexers are members that enables anIndexers are members that enables an object to be indexed in the same way asobject to be indexed in the same way as an arrayan array
  • 46. Indexer (Example)Indexer (Example) class IndexerClass {class IndexerClass { private int[] myArray = new int[100];private int[] myArray = new int[100]; public int this[int index] // indexer declarationpublic int this[int index] // indexer declaration {{ get { /* code for the get accessor */ }get { /* code for the get accessor */ } set { /* code for the get accessor */ }set { /* code for the get accessor */ } }} }} public class MainClass {public class MainClass { public static void Main() {public static void Main() { IndexerClass b = new IndexerClass();IndexerClass b = new IndexerClass(); b[3] = 256;b[3] = 256; b[5] = 1024;b[5] = 1024; for (int i=0; i<=10; i++)for (int i=0; i<=10; i++) Console.WriteLine("Element #{0} = {1}", i, b[i]);Console.WriteLine("Element #{0} = {1}", i, b[i]); }} }}
  • 47. DelegateDelegate • Delegates are objects that contain aDelegates are objects that contain a reference to a methodreference to a method – If the method is an instance method to aIf the method is an instance method to a particular objectparticular object • Delegate type contains a signatureDelegate type contains a signature – Which must match method to be calledWhich must match method to be called
  • 48. Delegate (Example)Delegate (Example) // delegate declaration// delegate declaration delegate void SimpleDelegate();delegate void SimpleDelegate(); // delegate instantiation and invocation// delegate instantiation and invocation class Test {class Test { static void F() {static void F() { System.Console.WriteLine("Test.F");System.Console.WriteLine("Test.F"); }} static void Main() {static void Main() { SimpleDelegate d = new SimpleDelegate(F);SimpleDelegate d = new SimpleDelegate(F); d();d(); }} }}
  • 49. EventEvent public delegate void EventHandler(public delegate void EventHandler( object sender, EventArgs e);object sender, EventArgs e); public class Button: Controlpublic class Button: Control {{ public event EventHandler Click;public event EventHandler Click; protected void OnClick(EventArgs e) {protected void OnClick(EventArgs e) { if (Click != null) Click(this, e);if (Click != null) Click(this, e); }} }} void Initialize() {void Initialize() { Button b = new Button(...);Button b = new Button(...); b.Click += new EventHandler(ButtonClick);b.Click += new EventHandler(ButtonClick); }} void ButtonClick(object sender, EventArgs e) {void ButtonClick(object sender, EventArgs e) { MessageBox.Show("You pressed the button");MessageBox.Show("You pressed the button"); }}
  • 50. AttributeAttribute • How do you associate information withHow do you associate information with types and members?types and members? – Category of a propertyCategory of a property – Transaction context for a methodTransaction context for a method – XML persistence mappingXML persistence mapping • Traditional solutionsTraditional solutions – Add keywords or pragmas to languageAdd keywords or pragmas to language – Use external files (e.g., .IDL, .DEF)Use external files (e.g., .IDL, .DEF) • C# solution: AttributesC# solution: Attributes
  • 51. Attribute (Example)Attribute (Example) [Serializable][Serializable] public class Testpublic class Test {{ public Test()public Test() {{ }} [Obsolete("Bug!")][Obsolete("Bug!")] public void Do()public void Do() {{ // actions// actions }} }}