Download - Manual de Asignatura Programación C#
-
8/17/2019 Manual de Asignatura Programación C#
1/71
Manual de Asignatura
Programación
1
-
8/17/2019 Manual de Asignatura Programación C#
2/71
Contenido
INTRODUCCIÓN....................................................................................................................2
FICHA TÉCNICA.....................................................................................................................3
DESARROLLO DE CONTENIDOS......................................................................................... 6
DESARROLLO DE PRÁCTICAS..........................................................................................69
INSTRUMENTOS DE EVALUACIÓN....................................................................................70
BIBLIOGRAFÍA.....................................................................................................................72
2
-
8/17/2019 Manual de Asignatura Programación C#
3/71
INTRODUCCIÓN
E !"#$%&'(&) '*+'%'% ,),) -( #%!(*!#!$ +' ,!)%)(*!' /-) )!&) )(&%)
#%$1%'"'*!( $%!)(&',' ' $4)&$ 5 -( +)(1-'4) $%!)(&',$ ' $4)&$.
L' #%$1%'"'*!( $%!)(&',' ' $4)&$ ) -(' !+$$'8 -( "$,)+$ ,)
#%$1%'"'*!( *$( - &)$%' 5 - ")&$,$+$1' /-) *$(:!)() *$($*)% 5 )&-,!'%
'(&) ,) (','. U( +)(1-'4) $%!)(&',$ ' $4)&$ ) -( +)(1-'4) ,) #%$1%'"'*!( /-)
#)%"!&) )+ ,!);$ ,) '#+!*'*!$() $%!)(&',' ' $4)&$.
L' #%$1%'"'*!( $%!)(&',' ' $4)&$ '(,$ )+ +)(1-'4) ) #-),)( &%',-*!% )&$ -1%-#$ ' -(!,',) '-&$*$(&)(!,'
++'"',' $4)&$.
E+ &?%"!($ P%$1%'"'*!( O%!)(&',' ' O4)&$ @POO ',$ ) ,!*!+ ,) ,)!(!% 5' /-) ($ ) -( *$(*)#&$ (-):$ !($ /-)
-
8/17/2019 Manual de Asignatura Programación C#
4/71
FICHA TÉCNICA
Ficha Técnica - Programación
Nombra de a a!ignat"ra P%$1%'"'*!(#"!ti$icaciónOb%eti&o E+ '+-"($ 1)()%'%= -(' '#+!*'*!(
!($%"=&!*' -&!+!>'(,$ )+ #'%',!1"'
$%!)(&',$ ' $4)&$ )( -( +)(1-'4) ,)
#%$1%'"'*!( #'%' +' $+-*!( ,) -(
#%$+)"' )#)*!*$ '#+!*'(,$ -)('
#%=*&!*' ,) #%$1%'"'*!(.
Conocimiento! 're&io! M)&$,$+$1' ,) +' P%$1%'"'*!(
Ca'acidade! A!ociada!
4
-
8/17/2019 Manual de Asignatura Programación C#
5/71
Unidade! Tem(tica!Hora!
Pr(ctica! Teórica! Totae!
I F"ndamento! de 'rogramación
orientada a ob%eto!
6 10
II Ambiente de de!arroo de a POO 2 6
III Programación orientada a ob%eto! 36 44
I) Arrego! 2 6 18
) *ane%o de e+ce'cione! 0 2 12
Totae! , .. /0
Bibliografía
Autor Año Título del Documento
Arnow, David (2004
)
Introduction to programming using Java : an object-
oriented approach
Baltasar García,
J.
(2008
)
Metodología de la Programación
Cairo Battistuti
Osvaldo
(2004
)
Metodología De La Programación
Cairo Battistuti
Osvaldo
(2008
)
Metodología de La Programación: Algoritmos
Diagramas De !lujo " Programas #$% &d'(
Joyans
A!uilar "uis
(#$8
8)
Metodología de la Programación. Diagramas de Flujo,
Algoritmos Y Programación Estructurada
Joyans
A!uilar "uis
(#$$2
)
Problemas de Metodología de La Programación
%atc&ro',
alo
(200*
)
&l )ran libro de la Programación
"+- "oardo (200*
)
Metodología De La Programación *rientada A
*bjetos
5
-
8/17/2019 Manual de Asignatura Programación C#
6/71
Bibliografía
Autor Año Título del Documento
odrí!u-
Al/ida n!l1.
(#$
$#)
Metodología De La Programación a trav+s de
Pseudocódigo'
Di!trib"ción hora!1!emana de a! Unidade! Tem(tica!
Unidade! Tem(tica!
Hora! 2emana de
Im'articiónPractica! Teórica! Totae!
I3 F"ndamento! de
'rogramación orientada a
ob%eto!
6 10 1, 2
II3 Ambiente de de!arroo
de a POO 2 6 2, 3
III3 Programación orientada a
ob%eto!36 44
3, 4, 5, 6, 7,
8, 9, 10
I)3 Arrego! 2 6 18 11, 12 , 13)3 *ane%o de e+ce'cione! 0 2 12 14, 15
TOTA452 , .. /0
D52ARRO44O D5 CONT5NIDO2
6
-
8/17/2019 Manual de Asignatura Programación C#
7/71
Unidade! 6 Tema!
I3 F"ndamento! de 'rogramación orientada a ob%eto!3'. F-(,'")(&$ ,) +' POO. C'%'*&)%&!*' ,) +' POO
II3 Ambiente de de!arroo de a POO3'. G)()%'+!,',) ,) +' ,) ,)'%%$++$
III3 Programación orientada a ob%eto!3'. E&%-*&-%' =!*' ,) -(' *+'). A#)*&$ +?!*$*. C+') 5 O4)&$,. E&%-*&-%' ,) *$(&%$+). E(*'#-+'"!)(&$
. H)%)(*!'1. P$+!"$%!"$
I)3 Arrego!3'. D)!(!*!( ,) A%%)1+$. M'()4$ ,) '%%)1+$
)3 *ane%o de e+ce'cione!'. C$(*)#&$ 5 &!#$ ,) )*)#*!$().. M'()4$ ,) )*)#*!$().*. C%)'*!( 5 +'(>'"!)(&$ ,) )*)#*!$().
UNIDAD I3 F"ndamento! de 'rogramación orientada a ob%eto!3
I3I F"ndamento! de a POO
¿Qué es un paradigma de programación?
C$(4-(&$ ,)
-
8/17/2019 Manual de Asignatura Programación C#
8/71
',' #$% - '&%!-&$ #%$#!$ 5 *-5$
*$"#$%&'"!)(&$ )&= ,)&)%"!(',$ #$% +' '**!$() $ -(*!$() /-) #-),)(
"$,!!*'%+$ ' *$"$ &'"!?( +' '**!$() /-) %)/-!)%) ,) $&%$ $4)&$. P-),) )%
,)!(!,$ *$"$ -(' )(*'#-+'*!( 5 -(' '&%'**!( -(' )(*'#-+'*!( ,) '&%!-&$
5 )%:!*!$ 5 -(' '&%'**!( ,)+ "-(,$ %)'+.
P'%' )+ *$(&)&$ ,) POO -( $4)&$ ) -(' )(&!,', /-) )(*'#-+' ,'&$ @'&%!-&$ 5
'**!$() $ -(*!$() /-) +$ "'()4'( @"?&$,$. T'"!?( -( $4)&$ ) ,)!() *$"$
-(' !(&'(*!' $ #'%&!*-+'%!>'*!( ,) -(' *+').
L$ $4)&$ ,) !(&)%? ,-%'(&) )+ ,)'%%$++$ ,) $&'%) ($ +$ $( &$"',$ ,) +'
:!,' %)'+ @$4)&$ :!!+) $ &'(1!+) &'"!?( #-),)( )% '&%'*&$. E( 1)()%'+
$( )(&!,',) /-) 4-)1'( -( %$+ !)( ,)!(!,$ )( )+ ,$"!(!$ ,)+ #%$+)"'. U( +!%$
-(' #)%$(' -( *'%%$ -( #$+1$($ $( '#)(' '+1-($ )4)"#+$ ,) $4)&$.
C',' $4)&$ #-),) )% *$(!,)%',$ *$"$ -( #%$:)),$% ,) )%:!*!$ -&!+!>',$ #$%
$&%$ $4)&$ /-) $( - *+!)(&). C',' $4)&$ #-),) )% ' +' :)> #%$:)),$% 5
*+!)(&). D) '++ /-) -( #%$1%'"' #-),' )% :!&$ *$"$ -( *$(4-(&$ ,) %)+'*!$()
)(&%) #%$:)),$%) *+!)(&). L$ )%:!*!$ $%)*!,$ #$% +$ $4)&$ $( ,) ,$ &!#$
8
-
8/17/2019 Manual de Asignatura Programación C#
9/71
. L$ ,'&$ /-) ++'"'"$ atributos. 2. L' '**!$() $ -(*!$() /-) ++'"'"$ m#todos.
$%ase
L' *+') ) +' -(!,', ,) "$,-+'%!,', )( +' POO. L' &)(,)(*!' ('&-%'+ ,)+ !(,!:!,-$) +' ,) *+'!!*'% +$ $4)&$ )1( - *'%'*&)%&!*' *$"-() @*+'). P$%
)4)"#+$ +' #)%$(' /-) '!&)( ' +' -(!:)%!,', ) #-),)( *+'!!*'% @
-
8/17/2019 Manual de Asignatura Programación C#
10/71
U( '&%!-&$ ) -(' *'%'*&)%&!*' ,) -( $4)&$. M),!'(&) +$ '&%!-&$ ) ,)!()
!($%"'*!( $*-+&' ,)(&%$ ,) -( $4)&$ +' *-'+ ) "'(!#-+',' $+'")(&) #$% +$
"?&$,$ ,)!(!,$ $%) ,!*
I3II Caracter7!tica! de a POO
'!sracción
E )+ #%!(*!#!$ ,) !1($%'% '/-)++$ '#)*&$ ,) -( )(")($ $)%:',$ /-) ($ $(%)+):'(&) *$( )+ $4)&!:$ ,) *$(*)(&%'%) )( '/-)++$ /-) +$ $(. U('
'&%'**!( ,)($&' +' *'%'*&)%&!*' ))(*!'+) ,) -( $4)&$ @,'&$ 5 $#)%'*!$()
/-) +$ ,!&!(1-) ,) $&%' *+') ,) $4)&$. D)*!,!% )+ *$(4-(&$ *$%%)*&$ ,)
'&%'**!$() ,) -( ,)&)%"!(',$ ,$"!(!$ ) )+ #%$+)"' *)(&%'+ ,)+ ,!);$
$%!)(&',$ ' $4)&$.
L$ ")*'(!"$ ,) '&%'**!( $( -',$ )( +' POO #'%' )&%')% 5 ,)!(!% ,)+
"),!$ ' "$,)+'% - *'%'*&)%&!*' 5 - *$"#$%&'"!)(&$. D)(&%$ ,) +' POO $("-5 -',$ ")*'(!"$ ,) '&%'**!( +' G)()%'+!>'*!( +' A1%)1'*!( 5 +'
*+'!!*'*!(.
• L' 1)()%'+!>'*!$() )+ ")*'(!"$ ,) '&%'**!( "),!'(&) )+ *-'+ -(
*$(4-(&$ ,) *+') ,) $4)&$ $( '1%-#',$ )( -(' *+') ,) (!:)+ -#)%!$%
@S-#)%*+') ,$(,) +' )")4'(>' ,) +' *+') *$(&!&-5)(&) @S-*+')
$( )('&!>',' 5 +' ,!)%)(*!' )(&%) )++' $( !1($%','.•
L' '1%)1'*!( ) )+ ")*'(!"$ ,) '&%'**!( #$% )+ *-'+ -(' *+') ,) $4)&$) ,)!(!,' ' #'%&!% ,) - #'%&) @$&%' *+') ,) $4)&$.
• L' *+'!!*'*!( *$(!&) )( +' ,)!(!*!( ,) -(' *+') ' #'%&!% ,) -( *$(4-(&$
,) $4)&$ /-) &!)()( -( *$"#$%&'"!)(&$ !"!+'%.
10
-
8/17/2019 Manual de Asignatura Programación C#
11/71
(erencia
E )+ #%$*)$ "),!'(&) )+ *-'+ -( $4)&$ ,) -(' *+') ',/-!)%) #%$#!),',)
,)!(!,' )( $&%' *+') /-) +$ #%)*),' )( -(' 4)%'%/-' ,) *+'!!*'*!$(). P)%"!&) +'
,)!(!*!( ,) -( (-):$ $4)&$ ' #'%&!% ,) $&%$ '1%)1'(,$ +' ,!)%)(*!' )(&%) )++$):!&'(,$ %)#)&!*!( ,) *,!1$ 5 #)%"!&!)(,$ +' %)-'!+!,',.
L' *+')
-
8/17/2019 Manual de Asignatura Programación C#
12/71
*"$
*$( !1-'+ ($"%) ' ,!)%)(&) *+') $ )&=( %)+'*!$(',$ )( &?%"!($ ,) !(*+-!(.
E( )&) &!#$ ,) #$+!"$%!"$ +$ "?&$,$ $( !(&)%#%)&',$ )( )+ *$(&)&$ ,)+ $4)&$
#'%&!*-+'% 5' /-) +$ "?&$,$ *$( ($"%) *$"-() $( !"#+)")(&',$ ,)
,!)%)(&) "'()%' ,)#)(,!)(,$ ,) *',' *+').
Por ejem&lo, el 'rea de un cuadrado, rect'ngulo ( círculo, son calculados de manera
distinta) sin embargo, en sus clases res&ecti%as &uede e*istir la im&lementación del
'rea bajo el nombre com$n +rea. En la &r'ctica ( de&endiendo del objeto ue llame
al m#todo, se usar' el código corres&ondiente.
-tro ejem&lo de &olimorismo es el o&erador /. Este o&erador tiene dos unciones
dierentes de acuerdo al ti&o de dato de los o&erandos a los ue se a&lica. 0i los dos
elementos son num#ricos, el o&erador / signiica suma algebraica de los mismos,
en cambio si &or lo menos uno de los o&erandos es un 0tring o 1ar'cter, el o&erador
es la concatenación de cadenas de caracteres.
12
-
8/17/2019 Manual de Asignatura Programación C#
13/71
UNIDAD II3 Ambiente de de!arroo de a POO3
II3I 8eneraidade! de a herramienta de de!arroo
P'%' )+ *-%$ '*&-'+ ) ,)*!,! #'%' +' "'&)%!' -&!+!>'% )+ +)(1-'4) ,) #%$1%'"'*!(
CJ #$% +$ &'(&$ )+ IDE !,)'+ #'%' )+ ,)'%%$++$ ,) '#+!*'*!$() ) )+ V!-'+ S&-,!$
'-(/-) )!&)( $&%$ IDE +!%) #'%' )+ ,)'%%$++$ ,) ,!*
-
8/17/2019 Manual de Asignatura Programación C#
14/71
CJ ) -( +)(1-'4) ,) #%$1%'"'*!( /-) ) 5 ,)
=*!+ -$ 5 $&%'
-
8/17/2019 Manual de Asignatura Programación C#
15/71
?n!rs l o/r dl roycto, n nustro caso l lla/ar/os 1i roycto y@nal/nt da/os n l ot+n 6Actar7.
inal/nt s dsl!ar l ra d traa:o, con l cual s odr iniciar con la
ro!ra/aci+n
'!rir un proeco
15
-
8/17/2019 Manual de Asignatura Programación C#
16/71
P'%' #$,)% '%!% -( #%$5)*&$ )( V!-'+ S&-,!$ $+$ ) ()*)'%!$ !% '+ ")( A%*
@F!+) 5 ,'% )( +' A%!%8 @$#)( 5 )( +' $#*!( ,) P%$5)*&$S$+-*!(8
@P%$4)*&$+-&!$(
L$ *-'+ ,)#+)1'%= -(' :)(&'(' ,) )#+$%'*!( ,$(,) !"#+)")(&) ) ,))%=
)+)**!$('% )+ #%$5)*&$ ,))',$ 5 ,'% )( )+ $&( A%!%8
16
-
8/17/2019 Manual de Asignatura Programación C#
17/71
uardar
C-'(,$ ) *%)' -( #%$5)*&$ ) 1-'%,' #$% ,))*&$ )( +' %-&' )&'+)*!,'. L$ /-)
$*-%%) *$( )+ #%$*)$ ,) 1-'%,',$ ) /-) . G-'%,'% )+ *'"!$ )( )+ '%*
"$,!!*',$ )( )) "$")(&$ 2 G-'%,' )+ #%$5)*&$ )( $&%' %-&' ,) ,!%)*&$%!$ 3G-'%,'% &$,$ +$ *'"!$ ,) +$ '%*
P'%' #$,)% '**),)% '+ 1-'%,',$ ) ()*)'%!$ !% '+ ")( A%*
$)%:'% +' $#*!$() ,) 1-'%,',$ *$"$ )( +' !1-!)(&) !"'1)(.
O&%' $%"' ,)
-
8/17/2019 Manual de Asignatura Programación C#
18/71
C$"$ ) #-),) $)%:'% ' *$(&!(-'*!( )+ *$"#!+',$% ($ '%%$4' )%%$% 5 ($ ,'
-(' -1)%)(*!' )( )&) *'$ '+&' )( )+ *,!1$ ($ +$ )("'%*' *$( -( %)*-',%$ 1%!
,$(,) ) )(*-)(&%' )+ )%%$%.
)"ecuar
U(' :)> !('+!>',$ )+ *,!1$ 5 /-) ($ *-)(&) *$( )%%$%) #%$!1-) +' '**!(
)4)*-&'%8 @$ ,)#-%'*!( #'%' :!-'+!>'% )+ *$"#$%&'"!)(&$ ,)+ *,!1$. P'%' )++$
:'"$ '+ ")( D)#-%'%8 @,)-1 5 )( +' $#*!( I(!*!'% !( ,)#-%'%8
18
-
8/17/2019 Manual de Asignatura Programación C#
19/71
E( *'$ ,) /-) )+ *,!1$ *-)(&$ *$( '+1-(' '($"'+' ) #%))(&'%= -(' +!&' ,)
)%%$%).
C$"$ )+ #%$5)*&$ /-) ) )+)**!$( ) A#+!*'*!( ,) *$($+'8 '#'%)*)%= -('
:)(&'(' *$"$ +' !1-!)(&)
epurar
L' $#*!( D)#-%'%8 1)()%' -( ,!'1(&!*$ '$(,$ ,)+ *,!1$ ,)'%%$++',$ #'%'
'**),)% '+ #%$*)$ ,) ,)#-%'*!( ) ")( D)#-%'%8 5 +' $#*!( I(!*!'% ,)#-%'*!(8
E( )+ *'$ ,) /-) )!&' -( )%%$% )( )+ *,!1$ ,) !(&'! '#'%)*)%= -(' :)(&'(' ,)
',:)%&)(*!' 5 #$&)%!$%")(&) +$ %)-+&',$ ,) ,!*
-
8/17/2019 Manual de Asignatura Programación C#
20/71
Unidad III3 Programación orientada a ob%eto!3
III3I 5!tr"ct"ra b(!ica de "na ca!e
U(' ,)*+'%'*!( ,) *+') $ &%-*& ) *$"$ -( #+'($ /-) ) -&!+!>' #'%' *%)'%
!(&'(*!' - $4)&$ )( &!)"#$ ,) )4)*-*!(. S! ,)!() -(' *+') $ -( &%-*&
++'"',$ P)%$( P)%$( ) )+ ($"%) ,)+ &!#$. S! ,)*+'%' ) !(!*!'+!>' -('
:'%!'+) # ,) &!#$ P)%$( ) ,!*) /-) # ) -( $4)&$ $ -(' !(&'(*!' ,) P)%$(. S)
#-),)( *%)'% :'%!' !(&'(*!' ,)+ "!"$ &!#$ P)%$( 5 *',' !(&'(*!' #-),) &)()%
,!)%)(&) :'+$%) )( - #%$#!),',) 5 *'"#$.
U(' *+') ) -( &!#$ ,) %))%)(*!'. C-'(,$ ) *%)' -( $4)&$ ,) +' *+') +'
:'%!'+) ' +' /-) ) '!1(' )+ $4)&$ $+$ !(*+-5) -(' %))%)(*!' ' ,!*'( #'%' "$,)+'% *$"#$%&'"!)(&$ "= *$"#+)4$
$ ,'&$ /-) ) #!)('( "$,!!*'% -(' :)> *%)',$ -( $4)&$ ,) *+').
S!(&'! C+')
class o/r d la clasE
Atriutos
1Ftodos o uncionalidads
U( )4)"#+$ ,) +' ,)*+'%'*!( ,) -(' *+') )%' +' !1-!)(&)
class Alu/noEpublic static void Main( string[] args )
E
20
-
8/17/2019 Manual de Asignatura Programación C#
21/71
E+ )4)"#+$ ,) '(&)%!$% ($ &!)() -(*!$('+!,', #)%$ #-),) '1%)1=%)+) -('
-(*!$('+!,', !"#+) *$"$ ) +' *'#&-%' ,) -( ($"%) )( *$($+' 5 +' !"#%)!( ,)+
($"%) -&!+!>'(,$ -( "?&$,$ #'%' )++$ )%= ()*)'%!$ *%)'% -( $4)&$ ,) +' *+').
Para conocer m's2 3tt&s244msdn.microsot.com4es5es4librar(4ms6786!9.as&*
III3II A!'ecto! é+ico!
ipos de daos
T$,$ +$ &!#$ ,) ,'&$ #%!"!&!:$ )( CJ $( $4)&$ )( )+ )#'*!$ ,)
($"%) S5&)". P'%' *',' &!#$ ,) ,'&$ ) #%$#$%*!$(' -( ($"%) *$%&$ $ '+!'.
P$% )4)"#+$ !(& ) )+ ($"%) *$%&$ *$%%)#$(,!)(&) ' S5&)".I(&32 5 ,$-+) ) +'
$%"' '%):!',' ,) S5&)".D$-+).
E( +' &'+' !1-!)(&) ) #%$#$%*!$(' +' +!&' ,) &!#$ ,) ,'&$ ,) CJ 5 -
'+!'. L$ #%!")%$ $*
-
8/17/2019 Manual de Asignatura Programación C#
22/71
rcisi+n si/l
double Doul Mio d unto
Notant d
rcisi+n dol
*4 >#,$*$K#K48*2K2K08 a
#,$*$K#K48*2K2K08
c#ar C&ar Ln carctr
Lnicod
#* Ií/olos Lnicod utili-ados n l
tto
bool Boola
n
Mio Boolan
l+!ico
8 Mru o als
ob'ect O:ct Mio as d todos
los otros tios
string Itrin! Lna scuncia d
caractrs
decim
al
Dci/
al
Mio rciso
raccionario o
int!ral, 9u
ud rrsntar
n/ros
dci/als con 2$
dí!itossi!ni@cativos
#28 P#.0 Q #0R28 a P.$ Q #028
Pa%a!ras c%ae *reseradas-
L' #'+'%' *+':) $( !,)(&!!*',$%) #%),)!(!,$ %))%:',$ /-) &!)()( -(
!1(!!*',$ )#)*!'+ #'%' )+ *$"#!+',$%. N$ ) #-),)( -&!+!>'% *$"$ !,)(&!!*',$%)
)( -( #%$1%'"' ' ")($ /-) !(*+-5'( )+ *'%=*&)% *$"$ #%)!4$. P$% )4)"#+$ !
) -( !,)(&!!*',$% :=+!,$ #)%$ ! ($ +$ ) #$%/-) ! ) -(' #'+'%' *+':).
E( +' #%!")%' &'+' ,) )&) &)"' ) )(-")%'( +' #'+'%' *+':) /-) $(
!,)(&!!*',$%) %))%:',$ )( *-'+/-!)% #'%&) ,) -( #%$1%'"' ,) CJ. E( +' )1-(,'
&'+' ) )(-")%'( +' #'+'%' *+':) *$(&)&-'+) )( CJ +' *-'+) $+'")(&)
&!)()( -( !1(!!*',$ )#)*!'+ )( -( *$(&)&$ ,) #%$1%'"' +!"!&',$ 5 ) #-),)(
22
https://msdn.microsoft.com/es-es/library/system.double(v=vs.90).aspxhttps://msdn.microsoft.com/es-es/library/system.char(v=vs.90).aspxhttps://msdn.microsoft.com/es-es/library/system.boolean(v=vs.90).aspxhttps://msdn.microsoft.com/es-es/library/system.boolean(v=vs.90).aspxhttps://msdn.microsoft.com/es-es/library/system.object(v=vs.90).aspxhttps://msdn.microsoft.com/es-es/library/system.string(v=vs.90).aspxhttps://msdn.microsoft.com/es-es/library/system.decimal(v=vs.90).aspxhttps://msdn.microsoft.com/es-es/library/system.decimal(v=vs.90).aspxhttps://msdn.microsoft.com/es-es/library/system.double(v=vs.90).aspxhttps://msdn.microsoft.com/es-es/library/system.char(v=vs.90).aspxhttps://msdn.microsoft.com/es-es/library/system.boolean(v=vs.90).aspxhttps://msdn.microsoft.com/es-es/library/system.boolean(v=vs.90).aspxhttps://msdn.microsoft.com/es-es/library/system.object(v=vs.90).aspxhttps://msdn.microsoft.com/es-es/library/system.string(v=vs.90).aspxhttps://msdn.microsoft.com/es-es/library/system.decimal(v=vs.90).aspxhttps://msdn.microsoft.com/es-es/library/system.decimal(v=vs.90).aspx
-
8/17/2019 Manual de Asignatura Programación C#
23/71
-&!+!>'% *$"$ !,)(&!!*',$%) -)%' ,) )) *$(&)&$. N$%"'+")(&) '+ '1%)1'%)
(-):' #'+'%' *+':) '+ +)(1-'4) CJ ?&' ) '1%)1'( *$"$ #'+'%' *+':)
*$(&)&-'+) #'%' ):!&'% )%%$%) )( #%$1%'"' )*%!&$ )( :)%!$() '(&)%!$%).
abstract as base bool
brea b%te case catc#
c#ar c#eced class const
continue decimal default delegate
do double else enum
event eplicit etern false
*nall% *ed &oat for
foreac# goto if implicit
in in (generic modi*er) int interface
internal is loc long
namespace ne+ null ob'ect
operator out out (generic modi*er) override
params private protected public
readonl% ref return sb%te
sealed s#ort si,eof stacalloc
static string struct s+itc#
t#is t#ro+ true tr%
t%peof uint ulong unc#eced
unsafe us#ort using virtual
void volatile +#ile
23
https://msdn.microsoft.com/es-es/library/sf985hc5.aspxhttps://msdn.microsoft.com/es-es/library/cscsdfbt.aspxhttps://msdn.microsoft.com/es-es/library/hfw7t1ce.aspxhttps://msdn.microsoft.com/es-es/library/c8f5xwh7.aspxhttps://msdn.microsoft.com/es-es/library/adbctzc4.aspxhttps://msdn.microsoft.com/es-es/library/5bdb6693.aspxhttps://msdn.microsoft.com/es-es/library/06tc147t.aspxhttps://msdn.microsoft.com/es-es/library/0yd65esw.aspxhttps://msdn.microsoft.com/es-es/library/x9h8tsay.aspxhttps://msdn.microsoft.com/es-es/library/74b4xzyw.aspxhttps://msdn.microsoft.com/es-es/library/0b0thckt.aspxhttps://msdn.microsoft.com/es-es/library/e6w8fe1b.aspxhttps://msdn.microsoft.com/es-es/library/923ahwt1.aspxhttps://msdn.microsoft.com/es-es/library/364x0z75.aspxhttps://msdn.microsoft.com/es-es/library/25tdedf5.aspxhttps://msdn.microsoft.com/es-es/library/900fyy8e.aspxhttps://msdn.microsoft.com/es-es/library/370s1zax.aspxhttps://msdn.microsoft.com/es-es/library/678hzkk9.aspxhttps://msdn.microsoft.com/es-es/library/5011f09h.aspxhttps://msdn.microsoft.com/es-es/library/sbbt4032.aspxhttps://msdn.microsoft.com/es-es/library/8627sbea.aspxhttps://msdn.microsoft.com/es-es/library/xhbhezf4.aspxhttps://msdn.microsoft.com/es-es/library/e59b22c5.aspxhttps://msdn.microsoft.com/es-es/library/67bxt5ee.aspxhttps://msdn.microsoft.com/es-es/library/zwc8s4fz.aspxhttps://msdn.microsoft.com/es-es/library/f58wzh21.aspxhttps://msdn.microsoft.com/es-es/library/b1e65aza.aspxhttps://msdn.microsoft.com/es-es/library/ch45axte.aspxhttps://msdn.microsoft.com/es-es/library/ttw7t8t6.aspxhttps://msdn.microsoft.com/es-es/library/13940fs2.aspxhttps://msdn.microsoft.com/es-es/library/5011f09h.aspxhttps://msdn.microsoft.com/es-es/library/z5z9kes2.aspxhttps://msdn.microsoft.com/es-es/library/ttw7t8t6.aspxhttps://msdn.microsoft.com/es-es/library/dd469484.aspxhttps://msdn.microsoft.com/es-es/library/5kzh1b5w.aspxhttps://msdn.microsoft.com/es-es/library/87d83y5b.aspxhttps://msdn.microsoft.com/es-es/library/7c5ka91b.aspxhttps://msdn.microsoft.com/es-es/library/scekt9xw.aspxhttps://msdn.microsoft.com/es-es/library/c5kehkcz.aspxhttps://msdn.microsoft.com/es-es/library/ctetwysk.aspxhttps://msdn.microsoft.com/es-es/library/z2kcy19k.aspxhttps://msdn.microsoft.com/es-es/library/51y09td4.aspxhttps://msdn.microsoft.com/es-es/library/edakx9da.aspxhttps://msdn.microsoft.com/es-es/library/9kkx3h3c.aspxhttps://msdn.microsoft.com/es-es/library/s53ehcz3.aspxhttps://msdn.microsoft.com/es-es/library/t3c3bfhx.aspxhttps://msdn.microsoft.com/es-es/library/dd469487.aspxhttps://msdn.microsoft.com/es-es/library/ebca9ah3.aspxhttps://msdn.microsoft.com/es-es/library/w5zay9db.aspxhttps://msdn.microsoft.com/es-es/library/st6sy9xe.aspxhttps://msdn.microsoft.com/es-es/library/bcd5672a.aspxhttps://msdn.microsoft.com/es-es/library/yzh058ae.aspxhttps://msdn.microsoft.com/es-es/library/acdd6hb7.aspxhttps://msdn.microsoft.com/es-es/library/14akc2c7.aspxhttps://msdn.microsoft.com/es-es/library/1h3swy84.aspxhttps://msdn.microsoft.com/es-es/library/d86he86x.aspxhttps://msdn.microsoft.com/es-es/library/88c54tsw.aspxhttps://msdn.microsoft.com/es-es/library/ybs77ex4.aspxhttps://msdn.microsoft.com/es-es/library/eahchzkf.aspxhttps://msdn.microsoft.com/es-es/library/cx9s2sy4.aspxhttps://msdn.microsoft.com/es-es/library/98f28cdx.aspxhttps://msdn.microsoft.com/es-es/library/362314fe.aspxhttps://msdn.microsoft.com/es-es/library/ah19swz4.aspxhttps://msdn.microsoft.com/es-es/library/06tc147t.aspxhttps://msdn.microsoft.com/es-es/library/dk1507sz.aspxhttps://msdn.microsoft.com/es-es/library/1ah5wsex.aspxhttps://msdn.microsoft.com/es-es/library/eahhcxk2.aspxhttps://msdn.microsoft.com/es-es/library/0yd65esw.aspxhttps://msdn.microsoft.com/es-es/library/58918ffs.aspxhttps://msdn.microsoft.com/es-es/library/x0sksh43.aspxhttps://msdn.microsoft.com/es-es/library/t98873t4.aspxhttps://msdn.microsoft.com/es-es/library/a569z7k8.aspxhttps://msdn.microsoft.com/es-es/library/chfa2zb8.aspxhttps://msdn.microsoft.com/es-es/library/cbf1574z.aspxhttps://msdn.microsoft.com/es-es/library/zhdeatwt.aspxhttps://msdn.microsoft.com/es-es/library/9fkccyh4.aspxhttps://msdn.microsoft.com/es-es/library/yah0tteb.aspxhttps://msdn.microsoft.com/es-es/library/x13ttww7.aspxhttps://msdn.microsoft.com/es-es/library/2aeyhxcd.aspxhttps://msdn.microsoft.com/es-es/library/sf985hc5.aspxhttps://msdn.microsoft.com/es-es/library/cscsdfbt.aspxhttps://msdn.microsoft.com/es-es/library/hfw7t1ce.aspxhttps://msdn.microsoft.com/es-es/library/c8f5xwh7.aspxhttps://msdn.microsoft.com/es-es/library/adbctzc4.aspxhttps://msdn.microsoft.com/es-es/library/5bdb6693.aspxhttps://msdn.microsoft.com/es-es/library/06tc147t.aspxhttps://msdn.microsoft.com/es-es/library/0yd65esw.aspxhttps://msdn.microsoft.com/es-es/library/x9h8tsay.aspxhttps://msdn.microsoft.com/es-es/library/74b4xzyw.aspxhttps://msdn.microsoft.com/es-es/library/0b0thckt.aspxhttps://msdn.microsoft.com/es-es/library/e6w8fe1b.aspxhttps://msdn.microsoft.com/es-es/library/923ahwt1.aspxhttps://msdn.microsoft.com/es-es/library/364x0z75.aspxhttps://msdn.microsoft.com/es-es/library/25tdedf5.aspxhttps://msdn.microsoft.com/es-es/library/900fyy8e.aspxhttps://msdn.microsoft.com/es-es/library/370s1zax.aspxhttps://msdn.microsoft.com/es-es/library/678hzkk9.aspxhttps://msdn.microsoft.com/es-es/library/5011f09h.aspxhttps://msdn.microsoft.com/es-es/library/sbbt4032.aspxhttps://msdn.microsoft.com/es-es/library/8627sbea.aspxhttps://msdn.microsoft.com/es-es/library/xhbhezf4.aspxhttps://msdn.microsoft.com/es-es/library/e59b22c5.aspxhttps://msdn.microsoft.com/es-es/library/67bxt5ee.aspxhttps://msdn.microsoft.com/es-es/library/zwc8s4fz.aspxhttps://msdn.microsoft.com/es-es/library/f58wzh21.aspxhttps://msdn.microsoft.com/es-es/library/b1e65aza.aspxhttps://msdn.microsoft.com/es-es/library/ch45axte.aspxhttps://msdn.microsoft.com/es-es/library/ttw7t8t6.aspxhttps://msdn.microsoft.com/es-es/library/13940fs2.aspxhttps://msdn.microsoft.com/es-es/library/5011f09h.aspxhttps://msdn.microsoft.com/es-es/library/z5z9kes2.aspxhttps://msdn.microsoft.com/es-es/library/ttw7t8t6.aspxhttps://msdn.microsoft.com/es-es/library/dd469484.aspxhttps://msdn.microsoft.com/es-es/library/5kzh1b5w.aspxhttps://msdn.microsoft.com/es-es/library/87d83y5b.aspxhttps://msdn.microsoft.com/es-es/library/7c5ka91b.aspxhttps://msdn.microsoft.com/es-es/library/scekt9xw.aspxhttps://msdn.microsoft.com/es-es/library/c5kehkcz.aspxhttps://msdn.microsoft.com/es-es/library/ctetwysk.aspxhttps://msdn.microsoft.com/es-es/library/z2kcy19k.aspxhttps://msdn.microsoft.com/es-es/library/51y09td4.aspxhttps://msdn.microsoft.com/es-es/library/edakx9da.aspxhttps://msdn.microsoft.com/es-es/library/9kkx3h3c.aspxhttps://msdn.microsoft.com/es-es/library/s53ehcz3.aspxhttps://msdn.microsoft.com/es-es/library/t3c3bfhx.aspxhttps://msdn.microsoft.com/es-es/library/dd469487.aspxhttps://msdn.microsoft.com/es-es/library/ebca9ah3.aspxhttps://msdn.microsoft.com/es-es/library/w5zay9db.aspxhttps://msdn.microsoft.com/es-es/library/st6sy9xe.aspxhttps://msdn.microsoft.com/es-es/library/bcd5672a.aspxhttps://msdn.microsoft.com/es-es/library/yzh058ae.aspxhttps://msdn.microsoft.com/es-es/library/acdd6hb7.aspxhttps://msdn.microsoft.com/es-es/library/14akc2c7.aspxhttps://msdn.microsoft.com/es-es/library/1h3swy84.aspxhttps://msdn.microsoft.com/es-es/library/d86he86x.aspxhttps://msdn.microsoft.com/es-es/library/88c54tsw.aspxhttps://msdn.microsoft.com/es-es/library/ybs77ex4.aspxhttps://msdn.microsoft.com/es-es/library/eahchzkf.aspxhttps://msdn.microsoft.com/es-es/library/cx9s2sy4.aspxhttps://msdn.microsoft.com/es-es/library/98f28cdx.aspxhttps://msdn.microsoft.com/es-es/library/362314fe.aspxhttps://msdn.microsoft.com/es-es/library/ah19swz4.aspxhttps://msdn.microsoft.com/es-es/library/06tc147t.aspxhttps://msdn.microsoft.com/es-es/library/dk1507sz.aspxhttps://msdn.microsoft.com/es-es/library/1ah5wsex.aspxhttps://msdn.microsoft.com/es-es/library/eahhcxk2.aspxhttps://msdn.microsoft.com/es-es/library/0yd65esw.aspxhttps://msdn.microsoft.com/es-es/library/58918ffs.aspxhttps://msdn.microsoft.com/es-es/library/x0sksh43.aspxhttps://msdn.microsoft.com/es-es/library/t98873t4.aspxhttps://msdn.microsoft.com/es-es/library/a569z7k8.aspxhttps://msdn.microsoft.com/es-es/library/chfa2zb8.aspxhttps://msdn.microsoft.com/es-es/library/cbf1574z.aspxhttps://msdn.microsoft.com/es-es/library/zhdeatwt.aspxhttps://msdn.microsoft.com/es-es/library/9fkccyh4.aspxhttps://msdn.microsoft.com/es-es/library/yah0tteb.aspxhttps://msdn.microsoft.com/es-es/library/x13ttww7.aspxhttps://msdn.microsoft.com/es-es/library/2aeyhxcd.aspx
-
8/17/2019 Manual de Asignatura Programación C#
24/71
L' #'+'%' *+':) *$(&)&-'+) ) -&!+!>'( #'%' #%$#$%*!$('% -( !1(!!*',$ *$(*%)&$
)( )+ *,!1$ !( )"'%1$ ($ $( #'+'%' %))%:',' ,) CJ. A+1-(' #'+'%'
*+':) *$(&)&-'+) *$"$ 'artia 5 :here &!)()( !1(!!*',$ )#)*!'+) )( ,$ $"= *$(&)&$.
add alias ascending
as%nc a+ait descending
d%namic from get
global group into
'oin let orderb%
partial (t%pe) partial (met#od) remove
select set value
var +#ere (generic t%pe constraint) +#ere (-uer% clause)
%ield
Decaración de &ariabe! 6 con!tante!3
U(' :'%!'+) %)#%))(&' -( :'+$% (-"?%!*$ $ ,) *',)(' $ -( $4)&$ ,) -('
*+'). E+ :'+$% /-) +' :'%!'+) '+"'*)(' #-),) *'"!'% #)%$ )+ ($"%) !1-) !)(,$
)+ "!"$. U(' :'%!'+) ) -( &!#$ ,) *'"#$. E( CJ +' :'%!'+) ) ,)*+'%'( *$( -(
&!#$ ,) ,'&$ 5 -(' )&!/-)&' *$(*%)&$.
S!(&'! V'%!'+)Mio d dato o/r d la varialS
E4)"#+$
int :alorEntero)
24
https://msdn.microsoft.com/es-es/library/cc713648.aspxhttps://msdn.microsoft.com/es-es/library/ms173212.aspxhttps://msdn.microsoft.com/es-es/library/cc713606.aspxhttps://msdn.microsoft.com/es-es/library/hh156513.aspxhttps://msdn.microsoft.com/es-es/library/hh156528.aspxhttps://msdn.microsoft.com/es-es/library/cc713622.aspxhttps://msdn.microsoft.com/es-es/library/dd264741.aspxhttps://msdn.microsoft.com/es-es/library/bb383978.aspxhttps://msdn.microsoft.com/es-es/library/ms228503.aspxhttps://msdn.microsoft.com/es-es/library/cc713620.aspxhttps://msdn.microsoft.com/es-es/library/bb384063.aspxhttps://msdn.microsoft.com/es-es/library/bb311045.aspxhttps://msdn.microsoft.com/es-es/library/bb311040.aspxhttps://msdn.microsoft.com/es-es/library/bb383976.aspxhttps://msdn.microsoft.com/es-es/library/bb383982.aspxhttps://msdn.microsoft.com/es-es/library/wbx7zzdd.aspxhttps://msdn.microsoft.com/es-es/library/6b0scde8.aspxhttps://msdn.microsoft.com/es-es/library/cc713642.aspxhttps://msdn.microsoft.com/es-es/library/bb384087.aspxhttps://msdn.microsoft.com/es-es/library/ms228368.aspxhttps://msdn.microsoft.com/es-es/library/a1khb4f8.aspxhttps://msdn.microsoft.com/es-es/library/bb383973.aspxhttps://msdn.microsoft.com/es-es/library/bb384067.aspxhttps://msdn.microsoft.com/es-es/library/bb311043.aspxhttps://msdn.microsoft.com/es-es/library/9k7k7cf0.aspxhttps://msdn.microsoft.com/es-es/library/cc713648.aspxhttps://msdn.microsoft.com/es-es/library/ms173212.aspxhttps://msdn.microsoft.com/es-es/library/cc713606.aspxhttps://msdn.microsoft.com/es-es/library/hh156513.aspxhttps://msdn.microsoft.com/es-es/library/hh156528.aspxhttps://msdn.microsoft.com/es-es/library/cc713622.aspxhttps://msdn.microsoft.com/es-es/library/dd264741.aspxhttps://msdn.microsoft.com/es-es/library/bb383978.aspxhttps://msdn.microsoft.com/es-es/library/ms228503.aspxhttps://msdn.microsoft.com/es-es/library/cc713620.aspxhttps://msdn.microsoft.com/es-es/library/bb384063.aspxhttps://msdn.microsoft.com/es-es/library/bb311045.aspxhttps://msdn.microsoft.com/es-es/library/bb311040.aspxhttps://msdn.microsoft.com/es-es/library/bb383976.aspxhttps://msdn.microsoft.com/es-es/library/bb383982.aspxhttps://msdn.microsoft.com/es-es/library/wbx7zzdd.aspxhttps://msdn.microsoft.com/es-es/library/6b0scde8.aspxhttps://msdn.microsoft.com/es-es/library/cc713642.aspxhttps://msdn.microsoft.com/es-es/library/bb384087.aspxhttps://msdn.microsoft.com/es-es/library/ms228368.aspxhttps://msdn.microsoft.com/es-es/library/a1khb4f8.aspxhttps://msdn.microsoft.com/es-es/library/bb383973.aspxhttps://msdn.microsoft.com/es-es/library/bb384067.aspxhttps://msdn.microsoft.com/es-es/library/bb311043.aspxhttps://msdn.microsoft.com/es-es/library/9k7k7cf0.aspx
-
8/17/2019 Manual de Asignatura Programación C#
25/71
U(' *$(&'(&) ) $&%$ &!#$ ,) *'"#$. C$(&!)() -( :'+$% /-) ) '!1(' *-'(,$
) *$"#!+' )+ #%$1%'"' 5 (-(*' *'"!' ,)#-?. L' *$(&'(&) ) ,)*+'%'( *$( +'
#'+'%' *+':) ;con!t4librar(4?e?"(t*
-
8/17/2019 Manual de Asignatura Programación C#
26/71
CJ '#+!*' +$ $#)%',$%) )( +' )#%)!$() '%!&"?&!*' )( -(' )*-)(*!'
#%)*!' +' *-'+ ) ,)&)%"!(' )( ') ' +' !1-!)(&) %)1+' ,) #%)*),)(*!' ,)
$#)%',$%) /-) #$% +$ 1)()%'+ $( +' "!"' /-) +' /-) ) !1-)( )( =+1)%'
. P%!")%$ ) '#+!*'( +' $#)%'*!$() ,) "-+&!#+!*'*!( ,!:!!( 5 %)!,-$. S!-(' )#%)!( *$(&!)() :'%!' ,) )&' $#)%'*!$() +$ $#)%',$%) )
'#+!*'( ,) !>/-!)%,' ' ,)%)*/-!)%,' '
,)%)*
-
8/17/2019 Manual de Asignatura Programación C#
27/71
O#)%',$% )&=(,'%
'+1)%'!*$ ,) !1-'+,',
5 %)+'*!$('+)
O#)%',$% ,) !1-'+,', $
%)+'*!$('+ )( CJE4)"#+$
S!1(!!*',$ ,) +'
*$(,!*!(
-&erado de igualdad W WW WW 5 ) !1-'+ ' 5X YW YW 5 ($ ) !1-'+ ' 5
-&eradores
relacionales 5 ) "'5$% /-) 5 5 ) ")4$% /-) 5Z W W ) "'5$% $ !1-'+ /-) 5[ W W ) ")($% $ !1-'+ /-) 5
T'"!?( )
-
8/17/2019 Manual de Asignatura Programación C#
28/71
S! )+ $#)%',$% QQ) *$+$*' &%' )+ ($"%) ,) +' :'%!'+) @*$"$ )( )+ )4)"#+$
,):-)+:) )+ :'+$% ,) +' :'%!'+) '(&) ,) !(*%)")(&'%+' "!)(&%' /-) ! ) *$+$*'
'(&) ,):-)+:) )+ :'+$% ,) ?&' &%' !(*%)")(&'%+' 5 +$ "!"$ $*-%%) *$( )+
$#)%',$% . P$% )4)"#+$
c ; b//) 44 0e asigna a c el %alor de b ( luego se incrementa b
c ; //b) 44 0e incrementa el %alor de b ( luego se asigna a c
o L1!*$.
S) !(*+-5)( $#)%',$%) /-) #)%"!&)( %)'+!>'% +' $#)%'*!$() +1!*' &#!*'
'(,8 @\\5 \ $%8 @]]5 ] ($&8 @Y 5 $%8 @^
L$ $#)%',$%) \\ 5 ]] ) ,!)%)(*!' ,) \ 5 ] )( /-) +$ #%!")%$ %)'+!>'():'+-'*!( #)%)>$' 5 +$ )1-(,$ ($. L' ):'+-'*!( #)%)>$' *$(!&) )( /-) !
)+ %)-+&',$ ,) ):'+-'% )+ #%!")% $#)%'(,$ #)%"!&) ,),-*!% )+ %)-+&',$ ,) +'
$#)%'*!( )(&$(*) ($ ) ):'+' )+ )1-(,$ 5 ) ,):-)+:) ,!*$' *$(!&) )( ):'+-'% !)"#%)
'"$ $#)%'(,$.
o O#)%',$% *$(,!*!$('+.
E )+ (!*$ $#)%',$% !(*+-!,$ )( CJ /-) &$"' 3 $#)%'(,$ 5 ) -' '
*$(,!*!( _)#%)!( )#%)!(2
E+ !1(!!*',$ ,)+ $#)%'(,$ ) )+ !1-!)(&) ) ):'+' *$(,!*!(S! ) *!)%&' )
,):-)+:) )+ %)-+&',$ ,) ):'+-'% )#%)!(5 ! ) '+' ) ,):-)+:) )+ %)-+&',$
,) ):'+-'% *$(,!*!(2. U( )4)"#+$ ,) - -$ )
W @'0 _ ' 0 S-#$()"$ ' 5 ,) &!#$ )(&)%$
E( )&) )4)"#+$ ! )+ :'+$% ,) +' :'%!'+) ') -#)%!$% ' 0 ) '!1('%= ' )+ :'+$% ,)
' "!)(&%' /-) )( *'$ *$(&%'%!$ )+ :'+$% /-) ) +) '!1('%= )%= 0.
$omenarios
28
-
8/17/2019 Manual de Asignatura Programación C#
29/71
L$ *'%'*&)%) *$(:!)%&)( )+ %)&$ ,) +' +()' )( -( *$")(&'%!$. U( +$/-)
,) &)&$ &'"!?( ) #-),) *$(:)%&!% )( *$")(&'%!$ ! ) *$+$*' )(&%) +$
*'%'*&)%) 5 *$"$ #$% )4)"#+$
H)++$ `$%+,Y #%$1%'" !( CJ
H)++$ `$%+,Y #%$1%'" !( CJ.
T
iera%es
U( +!&)%'+) +' %)#%))(&'*!( )#+*!&' ,) +$ :'+$%) /-) #-),)( &$"'% +$ &!#$
=!*$ ,)+ +)(1-'4). A *$(&!(-'*!( ) )#+!*' *-=+ ) +' !(&'! *$( /-) )
)*%!)( +$ +!&)%'+) )( CJ ,)1+$=(,$+$ )1( )+ &!#$ ,) :'+$%) /-)
%)#%))(&'( )#%)!$().
o L!&)%'+) )(&)%$.
U( (")%$ )(&)%$ ) #-),) %)#%))(&'% )( CJ &'(&$ )( $%"'&$ ,)*!"'+ *$"$
-
8/17/2019 Manual de Asignatura Programación C#
30/71
L$ (!*$ +!&)%'+) +1!*$ :=+!,$ $( &%-) 5 '+) /-) %)#)*&!:'")(&)
%)#%))(&'( +$ :'+$%) +1!*$ *!)%&$ 5 '+$.
o L!&)%'+) ,) *'%=*&)%.
P%=*&!*'")(&) *-'+/-!)% *'%=*&)% ) #-),) %)#%))(&'% )(*)%%=(,$+$ )(&%) *$"!++'
!"#+). P$% )4)"#+$ b'b@+)&%' ' b b@*'%=*&)% ,) )#'*!$ b_b @"$+$ ,)
!(&)%%$1'*!( )&*. L' (!*' )*)#*!$() ' )&$ $( +$ *'%'*&)%) /-) )
"-)&%'( )( +' &'+' ' *$(&!(-'*!(
C'%=*&)% C,!1$ ,) )*'#) U(!*$,) C,!1$ ,) )*'#) )#)*!'+C$"!++' !"#+) c-0027 cd
C$"!++' ,$+) cC$"!++' ,$+) c-0022 ceC'%=*&)% (-+$ c-0000 c0
A+'%"' c-0007 c'R)&%$*)$ c-000 cS'+&$ ,) #=1!(' c-000C c N-):' +()' c-000A c(R)&$%($ ,) *'%%$ c-000D c% T'-+'*!( $(&'+ c-0009 c&T'-+'*!( :)%&!*'+ c-000B c:B'%%' !(:)%&!,' c-00aC cc
o L!&)%'+) ,) *',)('.
U(' *',)(' ($ ) "= /-) -(' )*-)(*!' ,) *'%'*&)%) )(*)%%',$ )(&%) *$"!++'
,$+). P$% )4)"#+$ eH$+' "-(,$e e*'"!(e )&*. E+ &)&$ *$(&)(!,$ ,)(&%$ )&$
+!&)%'+) #-),) )&'% $%"',$ #$% *-'+/-!)% (")%$ ,) +!&)%'+) ,) *'%=*&)%
*$(*'&)(',$ 5 !( +' *$"!++' !"#+) '-(/-) ! !(*+-5) *$"!++' ,$+) ?&'
-
8/17/2019 Manual de Asignatura Programación C#
31/71
o L!&)%'+ (-+$.
E+ +!&)%'+ (-+$ ) -( :'+$% )#)*!'+ /-) ) %)#%))(&' )( CJ *$( +' #'+'%' %))%:','
n" 5 ) -' *$"$ :'+$% ,) +' :'%!'+) ,) $4)&$ ($ !(!*!'+!>',' #'%' ' !(,!*'%
/-) *$(&!)()( %))%)(*!' (-+'.
)presiones
U(' )#%)!( ) -(' )*-)(*!' ,) -($ $ "= $#)%'(,$ 5 *)%$ $ "=
$#)%',$%) /-) ) #-),)( ):'+-'% *$"$ -( :'+$% $4)&$ "?&$,$ $ )#'*!$ ,)
($"%) (!*$. L' )#%)!$() #-),)( *$(&'% ,) -( :'+$% +!&)%'+ -(' !(:$*'*!(
,) "?&$,$ -( $#)%',$% 5 - $#)%'(,$ $ -( ($"%) !"#+). L$ ($"%) !"#+)
#-),)( )% )+ ($"%) ,) -(' :'%!'+) "!)"%$ ,) &!#$ #'%=")&%$ ,) "?&$,$
)#'*!$ ,) ($"%) $ &!#$.
L' )#%)!$() #-),)( -&!+!>'% $#)%',$%) /-) ' - :)> -&!+!>'( $&%'
)#%)!$() *$"$ #'%=")&%$ $ ++'"',' ' "?&$,$ *-5$ #'%=")&%$ $( ' -
:)> $&%' ++'"',' ' "?&$,$ ,) "$,$ /-) #-),)( :'%!'% ,) !"#+) ' "-5
*$"#+)4'. A *$(&!(-'*!( ) "-)&%'( ,$ )4)"#+$ ,) )#%)!$()
CC* 6! C * G " HH CC* G ! C* "
0(stem.1on%ert.oInt8CJ8"J
III3III Ca!e! 6 Ob%eto!
$%ases
L' !(&'! =!*' #'%' ,)!(!% -(' *+') ) +' /-) ' *$(&!(-'*!( ) "-)&%'
*+' ($"%)C+')
f
"!)"%$
g
31
-
8/17/2019 Manual de Asignatura Programación C#
32/71
D) )&) "$,$ ) ,)!(!%' -(' *+') ,) ($"%) ($"%)C+') *-5$
"!)"%$ $( +$ ,)!(!,$ )( "!)"%$L$ "!)"%$ ,) -(' *+') $( +$ ,'&$
5 "?&$,$ ,) +$ /-) :'( ' ,!#$()% &$,$ +$ $4)&$ ,) +' "!"'. U( )4)"#+$ ,)
*"$ ,)*+'%'% -(' *+') ,) ($"%) A /-) ($ &)(1' (!(1( "!)"%$ ) +' !1-!)(&)
*+' A
f
g
U(' *+') ' ,)*+'%',' ($ ,!#$(,%= ,) (!(1( "!)"%$ ' )*)#*!( ,) +$
!"#+*!&'")(&) ,)!(!,$ ,) "'()%' *$"( #'%' &$,$ +$ $4)&$ /-) *%))"$ )(
CJ.
&éodos
U( "?&$,$ ) -( +$/-) ,) *,!1$ /-) *$(&!)() -(' )%!) ,) !(&%-**!$().
L$ #%$1%'"'
-
8/17/2019 Manual de Asignatura Programación C#
33/71
C$"$ ($"%) ,)+ "?&$,$ ) #-),) #$()% )( ($"%)M?&$,$*-'+/-!)%
!,)(&!!*',$% :=+!,$.
A-(/-) ) #$!+) )*%!!% "?&$,$ /-) ($ &$")( #'%=")&%$ ! -( "?&$,$ +$
&$"' ) '% )+ $#)%',$% &
U( "?&$,$ )&=&!*$ ) +$ "= #'%)*!,$ ' +$ /-) $( +' -(*!$() )( +$ +)(1-'4)
)&%-*&-%',$ @*$( +' ,!)%)(*!' /-) ) )(*-)(&%' )(*'#-+',$ )( -(' *+')
S! %)*$%,'"$ *',' :)> /-) *%)'"$ -( #%$1%'"' )( CJ ,))"$ )#)*!!*'% )+
"?&$,$ M'!(
33
-
8/17/2019 Manual de Asignatura Programación C#
34/71
saic oid &ain*sring@ args-
E+ "?&$,$ M'!( ) )&=&!*$ #'%' /-) )+ !&)"' $#)%'&!:$ #-),' ++'"'%+$
,!%)*&'")(&) !( &)()% /-) *%)'% -( $4)&$ ,) +' *+') /-) +$ *$(&!)().
o Llamada a m#todos
L' $%"' )( /-) ) #-),) ++'"'% ' -( "?&$,$ ,)#)(,) ,)+ &!#$ ,) "?&$,$ ,)+ /-)
) &%'&). S! ) -( "?&$,$ ,) $4)&$@"?&$,$ ($ )&=&!*$ )
-
8/17/2019 Manual de Asignatura Programación C#
35/71
ipoPar
-
8/17/2019 Manual de Asignatura Programación C#
36/71
L$ #'%=")&%$ #$% %))%)(*!' ) ,)!()( !1-'+ /-) +$ #'%=")&%$ ,) '+!,' #)%$
-&!&-5)(,$ )+ "$,!!*',$% o"t #$% )+ "$,!!*',$% re$3
o M#todos constructores.
C',' :)> /-) ) *%)' -(' *+') $ &%-*& ) ++'"' ' - *$(&%-*&$%. U(' *+') $
&%-*& #-),) &)()% :'%!$ *$(&%-*&$%) /-) &$"'( '%1-")(&$ ,!)%)(&). L$
*$(&%-*&$%) #)%"!&)( '+ #%$1%'"',$% )&'+)*)% :'+$%) #%),)&)%"!(',$ +!"!&'% +'
*%)'*!( ,) !(&'(*!' 5 )*%!!% *,!1$ +)!+) 5 =*!+ ,) +))%.
L$ *$(&%-*&$%) ,) -( &!#$ ,) ,'&$ $( "?&$,$ )#)*!'+) /-) ) ,)!()(
*$"$ "!)"%$ ,) ?&) 5 /-) *$(&!)()( *,!1$ ' )4)*-&'% *',' :)> /-) ) *%)) -(
$4)&$ ,) )) &!#$.
L' !(&'! =!*' ,) ,)!(!*!( ,) *$(&%-*&$%) *$(!&) )( ,)!(!%+$ *$"$
*-'+/-!)% $&%$ "?&$,$ #)%$ ,=(,$+) )+ "!"$ ($"%) /-))+ &!#$ ,) ,'&$ '+ /-)
#)%&)()*)( 5 ($ !(,!*'(,$ )+ &!#$ ,) :'+$% ,) %)&$%($ ,)!,$ ' /-) (-(*' #-),)(
,):$+:)% (','.
E ,)*!% ) -' +' !(&'!
modiicadores; nom!reipo;*par
A+ *$(&%-*&$% ,) -(' *+') ) +) ++'"' )( )+ "$")(&$ )( /-) ) *%)' '+1( $4)&$
,) +' "!"' -'(,$ )+ $#)%',$% (). D)
-
8/17/2019 Manual de Asignatura Programación C#
37/71
/sem$onso%eCrie*D$reado o!"eo E=0>F,-G
>
pu!%ic saic oid &ain*- =
Prue!a p E neB Prue!a*5-G
>
>
o M?&$,$ *$(&%-*&$% #$% ,))*&$
N$ ) $+!1'&$%!$ ,)!(!% -( *$(&%-*&$% #'%' *',' *+') 5 )( *'$ ,) /-) ($
,)!('"$ (!(1-($ )+ *$"#!+',$% *%)'%= -($ #$% ($$&%$ !( #'%=")&%$ (!
!(&%-**!$(). E ,)*!% *$"$ ! ) *+' )(&%) )+ *$(*)#&$ ,) *'"#$ 5 )+ *$(*)#&$ ,)
"?&$,$. E&)%('")(&) ) '**),!,' *$"$ ! ,) -( *'"#$ ($%"'+ ) &%'&') #)%$
!(&)%('")(&) ) #$!+) '$*!'% *,!1$ ' )4)*-&'% )( *',' '!1('*!( $ +)*&-%' ,) -
:'+$%.
P'%' ,)!(!% -(' #%$#!),', )-' +' !1-!)(&) !(&'!
&!#$P%$#!),', ($"%)P%$#!),',f
)&
f
*,!1$E*%!&-%'
g
37
-
8/17/2019 Manual de Asignatura Programación C#
38/71
1)&
f
*,!1$L)*&-%'
g
g
U(' #%$#!),', ' ,)!(!,' )%' '**),!,' *$"$ ! ,) -( *'"#$ ,) &!#$
&!#$P%$#!),', ) &%'&') #)%$ )( *',' +)*&-%' ,) - :'+$% ) )4)*-&'%' )+
*,!1$L)*&-%' 5 )( *',' )*%!&-%' ,) -( :'+$% )( )++' ) )4)*-&'%'
*,!1$E*%!&-%'
A+ )*%!!% +$ +$/-) ,) *,!1$ 1)& 5 )&
-
8/17/2019 Manual de Asignatura Programación C#
39/71
*+' P)%$('
f
&%!(1 N$"%) C'"#$ ,) *',' $4)&$ P)%$(' /-) '+"'*)(' - ($"%)
!(& E,', C'"#$ ,) *',' $4)&$ P)%$(' /-) '+"'*)(' - ),',
&%!(1 NIF C'"#$ ,) *',' $4)&$ P)%$(' /-) '+"'*)(' - NIF
:$!, C-"#+)';$@ I(*%)")(&' )( -($ +' ),', ,)+ $4)&$ P)%$('
f
E,',QQ
g
P)%$(' @&%!(1 ($"%) !(& ),', &%!(1 (! C$(&%-*&$%f
N$"%) W ($"%) E,', W ),',
NIF W (!
g
g
P$,)"$ *%)'% -( $4)&$ P)%$(' ,) ($"%) $? ,) 22 ';$ ,) ),', 5 NIF2332A '
neB Persona*DHoséF, 22, D12344321I'F-
U(' :)> *%)',$ -( $4)&$ +$ "= ($%"'+ ) '+"'*)('% +' ,!%)**!( ,):-)+&'
#$% () )( -(' :'%!'+) ,)+ &!#$ '#%$#!',$ #'%' )+ $4)&$ *%)',$. E+ !1-!)(&)
)4)"#+$ /-) *$"$ ) +1!*$ !%= ,)(&%$ ,) +' ,)!(!*!( ,) '+1( "?&$,$ "-)&%'
*"$ *%)'% -(' :'%!'+) ,) &!#$ P)%$(' ++'"',' ' 5 *"$ '+"'*)('% )( )++' +'
,!%)**!( ,)+ $4)&$ /-) ,):$+:)%' +' '(&)%!$% '#+!*'*!( ,)+ $#)%',$% ()
Persona pG JJ $reamos aria!%e p
JJ '%macenamos en p e% o!"eo creado con neB
p E neB Persona*DHoseF, 22, D12344321I'F-G
39
-
8/17/2019 Manual de Asignatura Programación C#
40/71
A #'%&!% ,) )&) "$")(&$ +' :'%!'+) # *$(&)(,%= -(' %))%)(*!' ' -( $4)&$
,) *+') P)%$(' /-) %)#%))(&'%= ' -(' #)%$(' ++'"',' $? ,)22 ';$ 5 NIF
2332A. O +$ /-) #%=*&!*'")(&) ) +$ "!"$ 5 -)+) )% +' $%"' *$"(")(&)
-',' #'%' ,)*!%+$ +' :'%!'+) # %)#%))(&' ' -(' #)%$(' ++'"',' $? ,) 22 ';$
5 NIF 2332A.
C$"$ +$ "= ($%"'+ -)+) )% *%)'% :'%!'+) ,$(,) '+"'*)('% %))%)(*!' '
$4)&$ /-) *%))"$ +' !(&%-**!$() '(&)%!$%) #-),)( *$"#'*&'%) )( -(' $+'
'
Persona p E neB Persona*DHoséF, 22, D12344321I'F-G
D)
+'
-
8/17/2019 Manual de Asignatura Programación C#
41/71
/amp%e$%ass samp%e#!"ec E neB /amp%e$%ass*-G JJKi%iAando consrucor por
deeco
U(' :)> *%)',' +' !(&'(*!' ,) -(' *+') #-),) '!1('% :'+$%) ' +'
#%$#!),',) 5 +$ *'"#$ ,) +' !(&'(*!' ' *$"$ !(:$*'% "?&$,$ ,) *+').
'"#+)O4)*&.'"#+)P%$#)%&5 W S'"#+) S&%!(1 A!1('*!( ,) :'+$%
-&!+!>'(,$ #%$#!),',)
'"#+)O4)*&.'"#+)M)&
-
8/17/2019 Manual de Asignatura Programación C#
42/71
P$% +$ 1)()%'+ +' !(&%-**!$() )( -(' '#+!*'*!( ) )4)*-&'( -(' ,)#-?
,) +' $&%' )( )+ $%,)( )( /-) ) )*%!!)%$(. A )&) #%$*)$ ) +) *$($*) *$"$
)4)*-*!( )*-)(*!'+. V'%!' !(&%-**!$() ,) CJ +) #)%"!&)( )#)*!!*'% /-) +'
!1-!)(&) !(&%-**!( ' )4)*-&'% ($ ) ()*)'%!'")(&) +' !1-!)(&) )( +' )*-)(*!'. A
)&$ ) +) *$($*) *$"$ transerencia de control .
P'%' &$,' +' )&%-*&-%' ,) *$(&%$+ )*)#&$ +' !(&%-**!( s?itc3 +'
&%'()%)(*!' ,)+ *$(&%$+ ,)+ #%$1%'"' ) '' )( -(' ,)*!!( *-5$ %)-+&',$ )
-(' !(&%-**!( ,)+ :'+$% ,) :)%,', @/-) ,):-)+:) -( &!#$ $$+)'($ &%-) $ '+). S)
*%)' -(' )#%)!( 5 ' *$(&!(-'*!( ) #%-)' ! - %)-+&',$ ) &%-). H'5 ,$
*+') #%!(*!#'+) ,) )&%-*&-%' ,) *$(&%$+ ,) #%$1%'"'.
)srucura de conro% de se%ección
L' )&%-*&-%' ,) )+)**!( )#)*!!*' %-&' '+&)%('&!:' #'%' )+ +-4$ ,)+
#%$1%'"' *%)'(,$ ,) )&) "$,$ -( #-(&$ ,) -(!( )( )+ #%$1%'"'.
o L' )&%-*&-%' ,) )+)**!( (!*' @i$
L' !(&%-**!( i$ #)%"!&) )4)*-&'% *!)%&' !(&%-**!$() +$ ! ) ,' -(' ,)&)%"!(','
*$(,!*!(. S- !(&'! ,) -$ ) +' !(&'!
i *condición;-
insrucciones +;
E+ !1(!!*',$ ,) )&' !(&%-**!( ) )+ !1-!)(&) ) ):'+' +' )#%)!( *$(,!*!(
/-) '( !(&%-**!$() ,) )+)**!( #'%' )+)1!% )(&%) +$
*-%$ '+&)%('&!:$ ,) '**!(. P$% )4)"#+$ -#$(1' /-) +' *'+!!*'*!( #'%' '#%$'%
-( )'")( ) ,) 60.
iC cali G; =!
1onsole.riteLineCJA&robadoJ)
42
-
8/17/2019 Manual de Asignatura Programación C#
43/71
L' !(&%-**!( ,)&)%"!(' ! +' *$(,!*!( *'+! W 60 ) :)%,',)%' $ '+'. S! +'
*$(,!*!( ) :)%,',)%' ) !"#%!") A#%$',$ 5 ) )4)*-&' +' !1-!)(&) !(&%-**!(
)( +' )*-)(*!'. S! +' *$(,!*!( ) '+' ($ ) !"#%!") (!(1( ")('4) 5 ) )4)*-&'
+' !1-!)(&) !(&%-**!( )( +' )*-)(*!'.
o L' )&%-*&-%' ,) )+)**!( ,$+) @i$333e!e
L' !(&%-**!( ,) )+)**!( !"#+) !%)'+!>' -(' '**!( !(,!*',' +$ *-'(,$ +'
*$(,!*!( ) :)%,',)%' )( *'$ *$(&%'%!$ ) $"!&) +' '**!(. L' !(&%-**!( ,)
)+)**!( ,$+) ! )+) ($ #)%"!&) )#)*!!*'% -(' '**!( ' %)'+!>'% *-'(,$ +'
*$(,!*!( ) :)%,',)%' 5 -(' '**!( ,!&!(&' *-'(,$ +' *$(,!*!( ) '+'.
i *condición;-
insrucciones+;
e%se
insrucciones)%se;
P$% )4)"#+$
iC cali G; =!
1onsole.riteLineCJA&robadoJ)
else
1onsole.riteLineCJKe&robadoJ)
L' !(&%-**!( !"#%!") A#%$',$ ! +' *'+!!*'*!( ) "'5$% $ !1-'+ ' 60 #)%$
!"#%!") R)#%$',$ ! ) ")($% ' 60. E( *-'+/-!)% *'$ ,)#-? ,) %)'+!>'% +'
!"#%)!( ) )4)*-&' +' !1-!)(&) !(&%-**!( )( +' )*-)(*!'.
o L' )&%-*&-%' ,) )+)**!( "+&!#+) @!:itch
L' !(&%-**!( !&*< #)%"!&) )4)*-&'% -($ - $&%$ +$/-) ,) !(&%-**!$() )1(
)+ :'+$% ,) -(' *!)%&' )#%)!(. S- )&%-*&-%' )
!&*< @)#%)!(
f
*') :'+$%+$/-)
!1-!)(&)A**!(
43
-
8/17/2019 Manual de Asignatura Programación C#
44/71
*') :'+$%2+$/-)2
!1-!)(&)A**!(
...
,)'-+&+$/-)D)'-+&
!1-!)(&)A**!(
g
E+ !1(!!*',$ ,) )&' !(&%-**!( ) )+ !1-!)(&) ) ):'+' )#%)!(. S! -
:'+$% ) :'+$% ) )4)*-&' )+ +$/-) ! ) :'+$%2 ) )4)*-&' +$/-)2 5
' #'%' )+ %)&$ ,) :'+$%) )#)*!!*',$. S! ($ ) !1-'+ ' (!(1-($,) )$ :'+$%) 5
) !(*+-5) +' %'"' ,)'-+& ) )4)*-&' )+ +$/-)D)'-+& #)%$ ! ($ ) !(*+-5) )#'' ,!%)*&'")(&) ' )4)*-&'% +' !(&%-**!( !1-!)(&) '+ !&*
-
8/17/2019 Manual de Asignatura Programación C#
45/71
%)'K
*') P'*$8
C$($+).`%!&)L!()@H$+' P'*$. M) '+)1%$ ,) :)%&)8
%)'K
,)'-+&
C$($+).`%!&)L!()@H$+' f0g8 '%1h0i
g
E&) #%$1%'"' %)*$($*) *!)%&$ ($"%) ,) #)%$(' /-) ) +) #-),)( #''%
*$"$ '%1-")(&$ '+ +'(>'%+$ 5 +) '+-,' ,) $%"' )#)*!'+. L' %'"' ,)'-+& )
!(*+-5) #'%' ,'% -( '+-,$ #$% ,))*&$ ' +' #)%$(' ($ %)*$($*!,'.
o E+ $#)%',$% *$(,!*!$('+ )( +()' @ ? @
CJ *-)(&' *$( )+ $#)%',$% *$(,!*!$('+ @_ /-) #-),) -&!+!>'%) )( +-1'% ,)
-(' !(&%-**!( !j)+). É&) ) )+ (!*$ $#)%',$% &)%('%!$)( CJ ) ,)*!% /-) -&!+!>'
&%) $#)%'(,$. E( *$(4-(&$ +$ $#)%'(,$ 5 +$ "$+$ _ $%"'( -(' )#%)!(
*$(,!*!$('+. E+ #%!")% $#)%'(,$ @' +' !>/-!)%,' ,)+ _ ) -(' )#%)!( $$+)'(' )
,)*!% -(' )#%)!( /-) ) ):'+' *$"$ -( :'+$% &!#$ $$+ &%-)@:)%,',)%$ $
'+)@'+$. E+ )1-(,$ $#)%'(,$ @)(&%) )+ _ 5 )+ ) )+ :'+$% ,) +' )#%)!(*$(,!*!$('+ ! +' )#%)!( $$+)'(' ) &%-)5 )+ &)%*)% $#)%'(,$ @' +' ,)%)*
-
8/17/2019 Manual de Asignatura Programación C#
46/71
o I(&%-**!( :hie.
L' !(&%-**!(
*!)%&' !(&%-**!(. S- !(&'! ,) -$ )
BOi%e *condición;-
insrucciones;
S- !1(!!*',$ ) )+ !1-!)(&) S) ):'+' +' *$(,!*!( !(,!*',' /-)
C$($+).`%!&)L!()@kH$+' f0gY8 '%1h'*&-'+i
'*&-'+ W '*&-'+ Q
g
E( )&) *'$ ! ) !(,!*' "= ,) -( '%1-")(&$ '+ ++'"'% '+ #%$1%'"' )
"$&%'%= #$% #'(&'++' -( ")('4) ,) '+-,$ #'%' *',' -($ ,) )++$. P'%' )++$ ) -'
-(' :'%!'+) '*&-'+ /-) '+"'*)(' *-=+ ) )+ (")%$ ,) '%1-")(&$ ' "$&%'% )(
*',' )4)*-*!( ,)+ ',' +$ /-) )
-
8/17/2019 Manual de Asignatura Programación C#
47/71
o continue) I(,!*' /-) ) ,$
!(&%-**!$()
L' (!*' ,!)%)(*!' ,)+ !1(!!*',$ ,),$...
#%!")%$ )4)*-&' +'!(&%-**!$() 5 +-)1$ "!%' +'*$(,!*!( #'%' :)% ! )
+),$ W C$($+).R)',L!()@
g
E&) #%$1%'"' #%)1-(&' '+ --'%!$ -(' *+':) 5 "!)(&%' ($ !(&%$,->*' +' *$%%)*&'@$? ($ *$(&!(-'%= )4)*-&=(,$). U(' :)> /-) !(&%$,-*!,' *$%%)*&'")(&) ,'%= -(
")('4) ,) !)(:)(!,' '+ --'%!$.
o I(&%-**!( $or
47
-
8/17/2019 Manual de Asignatura Programación C#
48/71
L' !(&%-**!( $% ) -(' :'%!'(&) ,)
/-) ) -)( )( !(&%-**!$() 5 +-)1$ ) %)):'+' *$(,!*!(%)#!&!?(,$) )+
#%$*)$
C$($+).`%!&)L!()@kH$+' f0gY8 '%1h'*&-'+i
A+ !1-'+ /-) *$(
*$"#'*&'% +' )*%!&-%' ,) *,!1$ ,$(,) ) %)'+!*) '+1( &%'&'"!)(&$ ' &$,$ +$
)+)")(&$ ,) -(' *$+)**!( /-) -)+) -( -$ "-5
-
8/17/2019 Manual de Asignatura Programación C#
49/71
E+ !1(!!*',$ ,) )&' !(&%-**!( ) "-5 )(*!++$ ) )4)*-&'(!(&%-**!$()
#'%' *',' -($ ,) +$ )+)")(&$ ,) +' *$+)**!( !(,!*','. )+)")(&$ ) -('
:'%!'+) ,) +$ +)*&-%' ,) &!#$ &!#$E+)")(&$ /-) '+"'*)('%= )( *',' "$")(&$ )+
)+)")(&$ ,) +' *$+)**!( /-) ) )&? #%$*)'(,$ 5 /-) #$,%= )% '**),!,' ,),)
!(&%-**!$().
E !"#$%&'(&) );'+'% /-)*$+)**!( ($ #-),) :'+)% (-++ #$%/-) )(&$(*)
'+&'%' -(' )*)#*!( ,) &!#$ S5&)".N-++R))%)(*)E*)#&!$( 5 /-)
&!#$E+)")(&$
+$ ,)&'++) %)+'&!:$ ' - !"#+)")(&'*!( !(&)%(' 5 +$ ,)4'%+) :!!+) '/-)++$
/-) #-),'( -'% *$( )1-%!,',. A,)"= ' ) +) ):!&' /-) *$")&'( )%%$%)
#$% "'(!#-+'% !(',)*-','")(&) "!)"%$ /-) ($ ,))%'( &$*'%.o S) '*!+!&' '+ *%)',$% ,)+ &!#$ +' #$&)%!$% "$,!!*'*!( ,)+ "!"$ #-) ! +$
#%$1%'"',$%) *+!)(&) ($ #-),)( '**),)% ' +$ "!)"%$ ($ :!!+) -
49
-
8/17/2019 Manual de Asignatura Programación C#
50/71
'#+!*'*!$() ($ ) :)%=( ')*&',' ! ?&$ *'"!'( $ ) )+!"!('(. G%'*!' '
)&$ ) #$!+) *%)'% !(!*!'+")(&) &!#$ ,) ,'&$ *$( -( ,!);$ )(*!++$ '-(/-)
#$*$ )!*!)(&) 5 ! #$&)%!$%")(&) ) ()*)'%!$ "$,!!*'%+$ #'%' '-")(&'% -
)!*!)(*!' )++$ #-),)
-
8/17/2019 Manual de Asignatura Programación C#
51/71
)#'*!$ ,) ($"%) $ ,)(&%$ ,) -(' !(&)%'> ",-+$ *+') $ )&%-*&-%' #)%$ ($
,)(&%$ ,) -( #%$*),!"!)(&$.
Protected
L' #'+'%' *+':) P%$&)*&), ,) +' !(&%-**!( ,) ,)*+'%'*!( )#)*!!*' /-)
+$ ) #-),) &)()% '**)$ ' +$ )+)")(&$ ,),) ,)(&%$ ,) +' "!"' *+') $ ,),)
-(' *+') ,)%!:',' ,) )++'. E+ *,!1$ !1-!)(&) "-)&%' -( )4)"#+$ ,) ,)*+'%'*!(
P%$&)*&),.
P%$&)*&), C+' *+'F$%M5H)!%
S+$ #-),) -'% P%$&)*&), )( )+ (!:)+ ,) *+') 5 +$ '+ ,)*+'%'% -( "!)"%$
,) -(' *+'). E ,)*!% #-),) ,)*+'%'% -( )+)")(&$ #%$&)1!,$ )( -(' *+') #)%$ ($
)( )+ (!:)+ ,) '%*
!(&)%'> ",-+$ )&%-*&-%' $ #%$*),!"!)(&$.
Pri&ate
L' #'+'%' *+':) P%!:'&) ,) +' !(&%-**!( ,) ,)*+'%'*!( )#)*!!*' /-) +$
) #-),) &)()% '**)$ ' +$ )+)")(&$ ,),) ,)(&%$ ,)+ "!"$ ",-+$ *+') $
)&%-*&-%'. E+ *,!1$ !1-!)(&) "-)&%' -( )4)"#+$ ,) ,)*+'%'*!( P%!:'&).
P%!:'&) (-")%F$%M)O(+5 A I(&)1)%
S+$ #-),) -&!+!>'% P%!:'&) )( )+ (!:)+ ,) ",-+$. E ,)*!% #-),) ,)*+'%'% -(
)+)")(&$ #%!:',$ ,)(&%$ ,) -( ",-+$ *+') $ )&%-*&-%' #)%$ ($ )( )+ (!:)+ ,)
'%*
-
8/17/2019 Manual de Asignatura Programación C#
52/71
E+ ")*'(!"$ ,)
!(&'!
ca!! nombreHi%aB@nombrePadreB
miembro!Hi%aB
A +'
-
8/17/2019 Manual de Asignatura Programación C#
53/71
T%''4',$%@&%!(1 ($"%) !(& -)+,$ ')@($"%)f
S-)+,$ W -)+,$g
g
E( )+ )4)"#+$ '(&)%!$% +' *+') T%''4',$% '% )+ *$(&%-*&$% ,)+ &%''4',$% )&) %)*!) +$ #'%=")&%$
,) ($"%) 5 -)+,$ )+ #'%=")&%$ ($"%) *$%%)#$(,) '+ *$(&%-*&$% ') /-) )(
)&) *'$ #)%&)()*) ' +' *+') P)%$('.
o M?&$,$ :!%&-'+)
E #$!+) ,)!(!% *+') *-5$ "?&$,$ )
o&erride ti'oDe&"etoB nombre*étodoBE'ar(metro!BG
n"e&oCódigoB
o C+') '&%'*&'
53
-
8/17/2019 Manual de Asignatura Programación C#
54/71
U(' *+') '&%'*&' ) '/-)++' /-) $%>$'")(&) )
-
8/17/2019 Manual de Asignatura Programación C#
55/71
E+ #$+!"$%!"$ ) %)!)%) ' +' #$!!+!,', ,) ,)!(!% "+&!#+) *+') *$(
-(*!$('+!,', ,!)%)(&) #)%$ *$( "?&$,$ $ #%$#!),',) ,)($"!(',$ ,) $%"'
!,?(&!*' /-) #-),)( -&!+!>'%) ,) "'()%' !(&)%*'"!'+) "),!'(&) *,!1$ *+!)(&) )(
&!)"#$ ,) )4)*-*!(.
P'%' ')% "= '% -(' "!"'
'**!( )( +$ #%$1%'"' ) -' )+ "!"$ ($"%) )( ,!)%)(&) "?&$,$ *$(
,!)%)(&) !%"' h(")%$ $%,)( 5 &!#$ ,) +$ #'%=")&%$i )+ *,!1$ ,)
#%$1%'"'*!( '$*!',$ ' *',' $%)*'%1' #-),) :'%!'%.
E4)"#+$
"!E"#+)',$.C$(&%'&'%@-'(8 V)(&'8 2a00
"!E"#+)',$.C$(&%'&'%@-'(8
"!E"#+)',$.C$(&%'&'%@-'(8 2a00
S$%))*%!&-%' h O:)%%!,!(1 i
S-*),) *-'(,$ -(' *+') B8
-
8/17/2019 Manual de Asignatura Programación C#
56/71
E4)"#+$
$%ase ranspore
#-+!* *+' T%'(#$%&)
f #-+!* !(& :)+$*!,',M'!"' W 0
#-+!* !(& #''4)%$ W 0
#-+!* :!%&-'+ :$!, C'"!('@
f
C$($+).`%!&)L!()@")&$,$ ++'"',$ ,),) &%'(#$%&)
g
g
$%ase 'uo
#-+!* *+' A-&$ T%'(#$%&)
f
#-+!* !(& #-)%&' W 0
#-+!* A-&$@!(& #''4)%$!(& :)+$*!,',M'!"'!(& (-")%$L+'(&' !(& #-)%&'
f
&
&
-
8/17/2019 Manual de Asignatura Programación C#
57/71
C$($+).`%!&)L!()@M)&$,$ ++'"',$ ,),) *+') A-&$
g
g
P'%' -&!+!>'% +' $%))*%!&-%' ,))"$ ,)!(!% )+ "?&$,$ ,)+ #',%) *$( +' #'+'%':!%&-'+ $ '&%'*& 5 )&$ #)%"!&!%= /-) #$,'"$ %)"#+'>'%+$ #$% "),!$ ,)+
%)"#+'>'%+$ )( )+ '"$ +' #'+'%' %))%:',' $:)%%!,) 5 *$( )$ )
%)"#+'>' )+ "?&$,$ 5 *-'(,$ -&!+!*)"$ +' -(*!( -&!+!>'%)"$ +' ,)+ H!4$.
Vota2 cuando utiliUamos abstract nos reerimos a un m#todo abstracto, el cual no
&uede ser utiliUado, en cambio %irtual si &uede ser utiliUado.
UNIDAD I)3 Arrego!3
I)3I De$inición de arrego!
U( '%%)1+$ ) -( 1%-#$ ,) :'%!'+) @++'"',' )+)")(&$ /-) *$(&!)()(
:'+$%) 5 &$,$ $( ,)+ "!"$ &!#$. L$ &!#$ ) ,!:!,)( )( ,$ *'&)1$%' #$% :'+$%
5 #$% %))%)(*!'. L$ '%%)1+$ $( &!#$ #$% %))%)(*!'. L$ )+)")(&$ ,) -( '%%)1+$
#-),)( )% &!#$ #$% :'+$% $ &!#$ #$% %))%)(*!'. P'%' %))%!%($ ' -( )+)")(&$ )(
)#)*!'+ )( -( '%%)1+$ )#)*!!*'"$ )+ ($"%) ,) +' %))%)(*!' '+ '%%)1+$ 5 )+
(")%$ ,) +' #$!*!( ,) )) )+)")(&$ )( )+ '%%)1+$. A+ (")%$ ,) +' #$!*!( ) +)
*$($*) *$"$ )+ (,!*) ,)+ )+)")(&$
. E( +' !1-!)(&) !1-%' ) "-)&%' -(' %)#%))(&'*!( +1!*' ,) -( '%%)1+$
&!#$ )(&)%$ ++'"',$ * /-) *$(&!)() 2 )+)")(&$.
57
-
8/17/2019 Manual de Asignatura Programación C#
58/71
U( (,!*) ,)) )% -( )(&)%$ ($ ()1'&!:$ &'"!?( #-),) )% -(' )#%)!(. P$%
)4)"#+$ ! '-"!"$ /-) +' :'%!'+) ' ) !1-'+ ' a 5 ) !1-'+ ' 6 )(&$(*) +'
!(&%-**!(
*h ' Q i QW 2
-"' 2 '+ )+)")(&$ *h i ,)+ '%%)1+$.
I)3I *ane%o de arrego!
Decaración 6 creación de arrego!
L' !(&'(*!' ,) +$ '%%)1+$ $*-#'( )#'*!$ )( ")"$%!'. A+ !1-'+ /-) +$
$4)&$ +$ '%%)1+$ ) *%)'( *$( +' #'+'%' *+':) ne:. P'%' *%)'% -(' !(&'(*!' ,)
-( '%%)1+$ ) )#)*!!*' )+ &!#$ 5 )+ (")%$ ,) )+)")(&$ ,)+ '%%)1+$ 5 )+ (")%$ ,)
)+)")(&$ *$"$ #'%&) ,) -(' )#%)!( ,) *%)'*!( ,) '%%)1+$ /-) -&!+!>' +'
#'+'%' *+':) (). D!*
-
8/17/2019 Manual de Asignatura Programación C#
59/71
E&' &'%)' &'"!?( #-),) ++):'%) ' *'$ )( ,$ #'$ *$"$ ) "-)&%' '
*$(&!(-'*!(
in @ cG ,)*+'%' +' :'%!'+) &!#$ '%%)1+$
c E neB in 12 @G *%)' )+ '%%)1+$ +$ '!1(' ' +' :'%!'+) &!#$ '%%)1+$
A%%)1+$ -(!,!")(!$('+)
in @ num!ersG
A%%)1+$ "-+&!,!")(!$('+)
sring , @ namesG
A%%)1+$ ,) '%%)1+$ @)*'+$(','!e @ @ scoresG
E( CJ +$ '%%)1+$ $( $4)&$ @) )#+!*' "= ',)+'(&) )( )&) &-&$%!'+
*-5' !(&'(*!' ,))( *%)'%). L$ !1-!)(&) )4)"#+$ "-)&%'( *"$ *%)'%
'%%)1+$
A%%)1+$ -(!,!")(!$('+)
in@ num!ers E neB in5@G
A%%)1+$ "-+&!,!")(!$('+)
sring,@ names E neB sring5,4@G
Iniciai9ar arrego!
CJ #%$#$%*!$(' "?&$,$ !"#+) 5 )(*!++$ #'%' !(!*!'+!>'% '%%)1+$ )( )+
"$")(&$ ,) +' ,)*+'%'*!( )(*)%%'(,$ +$ :'+$%) !(!*!'+) )(&%) ++':) @fg. L$
!1-!)(&) )4)"#+$ "-)&%'( ,!)%)(&) "$,$ ,) !(!*!'+!>'% ,!)%)(&) &!#$ ,)'%%)1+$.
N$&' S! ($ !(!*!'+!>' -(' "'&%!> )( )+ "$")(&$ ,) +' ,)*+'%'*!( -
"!)"%$ ) !(!*!'+!>'( '-&$"=&!*'")(&) *$( )+ :'+$% !(!*!'+ #%),)&)%"!(',$ #'%' )+
59
-
8/17/2019 Manual de Asignatura Programación C#
60/71
&!#$ ,) '%%)1+$. A,)"= ! ,)*+'%' -( '%%)1+$ *$"$ *'"#$ ,) -( &!#$ )
)&'+)*)%= *$( )+ :'+$% #%),)&)%"!(',$ (-++ *-'(,$ *%)) +' !(&'(*!' ,)+ &!#$.
o Arreglos unidimensionales
intWX numbers ; ne? intW"X Q6, , 8, ' -( !(!*!'+!>',$% *$"$ )+!1-!)(&)
intWX numbers ; Q6, , 8, ) #-),) $"!&!% *$"$ ) !(,!*' ' *$(&!(-'*!(
intW,X numbers ; ne? intW,X Q Q6, R, Q8,
-
8/17/2019 Manual de Asignatura Programación C#
61/71
o MatriU escalonada CmatriU de matrices
L' "'&%!*) )*'+$(',' ) #-),)( !(!*!'+!>'% *$"$ )( )+ !1-!)(&) )4)"#+$
intWXWX numbers ; ne? intWXWX Q ne? intWX Q,8, ,)($"!(',' (-")% 5 ' *$(&!(-'*!( '!1(' -( a '+ /-!(&$ )+)")(&$ ,) +'
"'&%!>
intWX numbers ; Q6!, 9, , 7, =, ",
-
8/17/2019 Manual de Asignatura Programación C#
62/71
f
#%!:'&) &%!(1 '+-"
#%!:'&) &%!(1 '%&!&
#-+!* &%!(1 A+-"
f
1)& f%)&-%( '+-"g
)& f'+-" W :'+-)g
g
#-+!* &%!(1 A%&!&
f
1)& f%)&-%( '%&!&g
)& f'%&!& W :'+-)g
g
g
UNIDAD )3 *ane%o de e+ce'cione!
)3I Conce'to 6 ti'o! de e+ce'cione!3
L' )*)#*!$() ) -&!+!>'( #'%' !(,!*'% /-) )
-
8/17/2019 Manual de Asignatura Programación C#
63/71
L$ #%$1%'"',$%) ,))%'( !(!*!'% )*)#*!$() *-'(,$ ) *-"#+' '+ ")($
-(' ,) +' !1-!)(&) *$(,!*!$()
• E+ "?&$,$ ($ #-),) !('+!>'% - -(*!$('+!,', ,)!(!,'.• S) %)'+!>' -(' ++'"',' !(',)*-',' ' -( $4)&$ '',' )( )+ )&',$ ,)+ $4)&$.• C-'(,$ -( '%1-")(&$ #'%' -( "?&$,$ #%$:$*' -(' )*)#*!(
5+ce'cione! 'rede$inida! com"ne!
E( )+ )#'*!$ ,) ($"%) S5&)" ,) +' BCL
-
8/17/2019 Manual de Asignatura Programación C#
64/71
• T5#)I(!>!'+!>'&!$(E*)#&!$(. H' $*-%%!,$ '+1-(' )*)#*!( '+ !(!*!'+!>'% +$
*'"#$ )&=&!*$ $ )+ *$(&%-*&$% )&=&!*$ ,) -( &!#$. E( I(()%E*)#&!$( )
!(,!*' *-=+ ).
)3II *ane%o de e+ce'cione!3
L$ #%$1%'"',$%) ,) CJ -'( +$/-) &%5 #'%' )#'%'% )+ *,!1$ '+ /-)
#-),) ')*&'% -(' )*)#*!(. L$ +$/-) *'&*< '$*!',$ ) -&!+!>'( #'%' *$(&%$+'%
+' )*)#*!$() %)-+&'(&). U( +$/-) !('++5 *$(&!)() *,!1$ /-) ) )4)*-&' *$(
!(,)#)(,)(*!' ,) /-) ) #%$,->*' $ ($ -(' )*)#*!( )( )+ +$/-) &%5 *$"$ +!)%'%
%)*-%$ '!1(',$ )( )+ +$/-) &%5.
E( +$ )4)"#+$ !1-!)(&) ) "-)&%' -(' !(&%-**!( &%5*'&*
-
8/17/2019 Manual de Asignatura Programación C#
65/71
C,!1$ #'%' "'()4'% +' )*)#*!( :' '/-.g!('++5f
C,!1$ /-) ) )4)*-&' ,)#-? ,) /-) )+ !(&)(&$ @5 #$!+)")(&) +'
*'#&-%' +$/-). A/- :'.g
U( +$/-) &%5 !( -( +$/-) *'&*< $ !('++5 #%$,-*) -( )%%$% ,)+ *$"#!+',$%.
)3III Creación 6 an9amiento de e+ce'cione!3
U(' :)> +'(>',' -(' )*)#*!( ) #$!+) )*%!!% *,!1$ /-) ) )(*'%1-) ,)
&%'&'%+'. P$% ,))*&$ ! )&) *,!1$ ($ ) )*%!) +' )*)#*!( #%$:$*' /-) +'
'#+!*'*!( '$%&) "$&%'(,$ -( ")('4) ,) )%%$%.
S! ) ,))' &%'&'% +' )*)#*!(
-
8/17/2019 Manual de Asignatura Programación C#
66/71
• C$"#%)(,) *+'%'")(&) #$% /-? #-),) #%$,-*!%) +' )*)#*!( 5 #-),)
!"#+)")(&'% -(' %)*-#)%'*!( *$(*%)&' *$"$ #),!% '+ --'%!$ /-) )*%!' -(
(-):$ ($"%) ,) '%*'% -(
*$(&%$+ ',!*!$('+.
&%5f T%5 &$ '**) ' %)$-%*).g*'&*< @S5&)".U('-&),A**)E*)#&!$( )
f C'++ ' *-&$" )%%$% +$11!(1 #%$*),-%). L$1E%%$%@) R)&
66
-
8/17/2019 Manual de Asignatura Programación C#
67/71
)+ %)*$+)*&$% ,) )+)")(&$ ($ -&!+!>',$ ,)+ "$&$% )( &!)"#$ ,) )4)*-*!( !('+!*) +$
$4)&$. P'%' $&)()% "= !($%"'*!( *$(-+&) -!(1 @I(&%-**!( R))%)(*!' ,)
CJ.
E( )+ )4)"#+$ !1-!)(&) )+ +$/-) !('++5 ) -' #'%' *)%%'% -( '%*
'%) )( )+ +$/-) &%5. O)%:) /-) ) *$"#%-)' )+ )&',$ ,)+ !,)(&!!*',$% ,)+
'%*
S5&)".IO.F!+)S&%)'" !+) W (-++S5&)".IO.F!+)I($ !+)!($ W () S5&)".IO.F!+)I($@Ccc!+).&&
&%5f !+) W !+)!($.O#)(`%!&)@ !+).`%!&)B5&)@0Fg!('++5f C
-
8/17/2019 Manual de Asignatura Programación C#
68/71
D52ARRO44O D5 PRCTICA2
N%er arc3i%o &rotocolo de &r'cticas &rogramaciónT
68
-
8/17/2019 Manual de Asignatura Programación C#
69/71
IN2TRU*5NTO2 D5 5)A4UACIÓN
LISTA DE COTEO PARA EERCICIOS
DA-0 ZEVEKALE0 DEL PK-1E0- DE E:ALA1I[V
N$"%)@ ,)+ '+-"($@ 5$ E/-!#$ F!%"' ,)+ '+-"($@
P%$,-*&$ N$"%) $ &)"' ,) +'T'%)'
F)*
-
8/17/2019 Manual de Asignatura Programación C#
70/71
N$"%) ,)+ D$*)(&) F!%"' ,)+ D$*)(&)
INSTRUCCIONES
R):!'% +' *'%'*&)%&!*' /-) ) $+!*!&'( 5 *'+!!/-) )( +' *$+-"(' V'+$% O&)(!,$8 )+ :'+$% '!1(',$ *$( %)#)*&$ '+ V'+$% ,)+ R)'*&!:$8. E( +' *$+-"(' OBSERVACIONES8
-
8/17/2019 Manual de Asignatura Programación C#
71/71
Criterios
Nivel.
4. Excelente (20) 3. Satisfactorio
(15)
2. Puede
Meorar (10)
1. !nadecuado
(0)
Razonamiento Usa pensamiento
completo yrefinado.
Usa pensamiento
efectivo.
l!"nas
evidencias de pensamiento
#o presenta
nin!$n tipo derazonamiento
n%lisis del tema. &em"estra "n
an%lisis prof"ndo
del tema.
&em"estra el
an%lisis correcto
del tema.
Un an%lisis con
errores.
#o presenta
nin!$n tipo de
an%lisis.
'omprensi(n del
tema.
&em"estra "na
comprensi(n
total del tema.
&em"estra "na
comprensi(n
acepta)le del
tema.
&em"estra "na
comprensi(n del
tema con errores.
#o dem"estra
nin!$n tipo de
comprensi(n del
tema.
plicaci(n de
procedimiento y
resol"ci(n
correcta de los
e*ercicios.
+a resol"ci(n de
los e*ercicios es
correcta y clara.
+a resol"ci(n de
los e*ercicios es
la adec"ada.
+a resol"ci(n de
los e*ercicios
presenta
deficiencias.
Una resol"ci(n
incorrecta de los
e*ercicios.
,ntre!a en tiempo
y forma
,ntre!a s"s
e*ercicios en
tiempo y forma
esta)lecidos
,ntre!a s"s
e*ercicios
li!eramente
inadec"ados en
tiempo y forma
,ntre!a s"s
e*ercicios
posteriormente
#o entre!a s"s
e*ercicios ni en
tiempo ni en
forma
P-(&'4) O&)(!,$ )( ') ' +' %%!*'
I4IO8RAFJA
B'+&'%'% G'%*!'. M)&$,$+$1' ,) +' P%$1%'"'*!( @200. P%)(&!*) H'++
H'%:)5 D)!&)+ 5 P'-+ . D)!&)+.CJ C"$ P%$1%'"'% @2007. D)!&)+