This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Punto | |
{ | |
public int X; // Abscisa X | |
public int Y; // Ordenada Y | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PuntoPrueba | |
{ | |
static void Main() | |
{ | |
Punto punto1 = new Punto(); | |
punto1.X = 7; | |
Punto punto2 = punto1; // Copia la referencia punto1 | |
Console.WriteLine(punto1.X); // 7 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NullPrueba | |
{ | |
static void Main() | |
{ | |
Punto punto = null; | |
Console.WriteLine(punto == null); // True | |
// Al intentar acceder a un dato miembro del objeto null | |
// en tiempo de ejecuci贸n se generar谩 un error |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct A | |
{ | |
byte b; // 1 bytes | |
long l; // 8 bytes | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TiposPrimitivos | |
{ | |
static void Main() | |
{ | |
// Prepresentaci贸n hexadecimal adyacente | |
int i = 7; // 0x7 | |
bool b = true; // 0x1 | |
char c = 'A'; // 0x41 | |
float f = 0.5f; // usa c贸dificaci贸n de punto flotante de la IEEE | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Incremento | |
{ | |
static void Main() | |
{ | |
int c; | |
// demuestra el operador de incremento postfijo | |
c = 5; // asigna 5 a c | |
Console.WriteLine(c); // Imprime 5 | |
Console.WriteLine(c++); // Imprime 5 otra vez, luego realiza el incremento |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Decremento | |
{ | |
static void Main() | |
{ | |
int c; | |
// demuestra el operador de decremento postfijo | |
c = 5; // asigna 5 a c | |
Console.WriteLine(c); // Imprime 5 | |
Console.WriteLine(c--); // Imprime 5 otra vez, luego realiza el decremento |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SinOperadorChecked | |
{ | |
static void Main() | |
{ | |
// Este ejemplo no produce error en tiempo de compilaci贸n. | |
int diez = 10; | |
int i = 2147483647 + diez; | |
// Por defecto, la sentencia anterior no produce ninguna | |
// excepci贸n en tiempo de ejecuci贸n. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UsoOperadorChecked | |
{ | |
static void Main() | |
{ | |
int diez = 10; | |
// Expresi贸n con operador checked | |
Console.WriteLine(checked(2147483647 + diez)); | |
// Bloque de c贸digo con operador checked |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
byte b = 53; | |
Console.WriteLine("{0:0}", Convert.ToString(b,2)); | |
byte notB = (byte)~b; | |
Console.WriteLine("{0:0}", Convert.ToString(notB,2)); |