public static void Main(string[] args) { object i = 33; Type type1 = i.GetType (); showType (type1); object s = "hola"; Type type2 = s.GetType (); showType (type2); Type typeX = typeof(string); showType (typeX); Type typeFoo = typeof(Foo); showType (typeFoo); Type type0 = typeof(object); showType (type0); Articulo articulo = new Articulo (); showType (articulo.GetType ()); articulo.Nombre = "nombre 33"; articulo.Categoria = 2; articulo.Precio = 3.5m; showObject (articulo); setValues (articulo, new object[] { 33L, "numero 33 modificado", decimal.Parse("33.33") }); showObject (articulo); }
public static void Main(string[] args) { //todo esto esta comentado porque vamos a trabajar con la clase Foo // el {0} coge el valor de la variable que hay a continuación // object i = 33; // Type typeI= i.GetType (); // //antes de crear el método utilizamos esto: Console.WriteLine ("typeI.Name={0}", typeI.Name); // showType (typeI); // // object s="hola"; // Type typeS = s.GetType (); // //antes de crear el método utilizamos esto: Console.WriteLine ("typeS.Name={0}", typeS.Name); // showType (typeS); // // Type typeX = typeof(string); // //antes de crear el método utilizamos esto: Console.WriteLine ("typeX.Name={0}", typeX.Name); // showType (typeX); // // Type typeO = typeof(object); //falla con object porque éste no tiene BaseType // showType (typeO); // // Type typeFoo = typeof(Foo); // showType (typeFoo); // muestra la clase Foo (el tipo: Foo) Articulo articulo = new Articulo (); // showType (articulo.GetType()); // articulo.Nombre = "nuevo 33"; // articulo.Categoria = 2; // articulo.Precio=decimal.Parse("3,5"); setValues (articulo, new object []{33L, "nuevo 33 modificado", 3L, decimal.Parse("33,33")}); showObject (articulo); }
public static void Main(string[] args) { // object i = 33; // Type typeI = i.GetType (); // // el {0} se utiliza para reemplazarlo por la variable typeI.Name // showType (typeI); // // object s = "Hola"; // Type typeS = s.GetType (); // showType (typeS); // // Type typeX = typeof(string); // showType (typeX); // Type typeFoo = typeof(Foo); // showType (typeFoo); // // Type typeO = typeof(object); // showType (typeO); Articulo articulo = new Articulo (); //ver el tipo //showType (articulo.GetType()); // articulo.Nombre = "nuevo 33"; // articulo.Categoria = 2; // articulo.Precio = decimal.Parse("3,5"); setValues(articulo,new object[]{33L,"nuevo 33 modificado",3L,decimal.Parse("33,33")}); showObject (articulo); }
public static void Main(string[] args) { // object i= 353; // Type typeI = i.GetType (); // showType (typeI); // // String s = ""; // Type typeS = s.GetType (); // showType (typeS); // // Type typeX = typeof(string); // showType (typeX); // // Type typeO = typeof(object); // showType (typeO); // Type typeFoo = typeof(Foo); // showType (typeFoo); Articulo articulo = new Articulo (); // articulo.Nombre = "nuevo 33"; // articulo.Categoria = 2; // articulo.Precio = decimal.Parse("3,5"); setValues(articulo, new object[]{ 33L,"nuevo 33 modificado",3L,decimal.Parse("33,33") }); showObject (articulo); }
public static void Main(string[] args) { /* int i=10; Type type = i.GetType (); //Tipo de i Console.WriteLine ("typeI.Name = {0}", type.Name); string s = "Hola mundo"; Type types = s.GetType (); // Tipo de String Console.WriteLine ("typeI.Name = {0}", types.Name); Type typeX = typeof(string); //Typeof se aplica a l Console.WriteLine ("typeI.Name = {0}", typeX.Name); showType (typeX); //Llamas al metodo que muestre el tipo */ //Type typeFoo = typeof(Foo); //tipo de la clase //showType (typeFoo); /* Type typeO = typeof(object); //Tipo de los objetos ,Object no tiene base type showType (typeO); */ Articulo articulo = new Articulo (); //Tipe de articulo showType(articulo.GetType()); articulo.Nombre = "nuevo 33"; articulo.Categoria = 2; articulo.Precio = decimal.Parse("3,5"); showObject (articulo); setValues (articulo, new object[]{33L,"nuevo 33 modificado",3L,decimal.Parse("33,33")}); }
public static void Main(string[] args) { /*int i = 33; Type typeI = i.GetType (); showType (typeI); string s="Algo"; Type typeS = s.GetType (); showType (typeS); Type typeX = typeof(string); showType (typeX); Type typeFoo = typeof(Foo); showType (typeFoo);*/ Articulo articulo = new Articulo (); //showType (articulo.GetType ()); articulo.Nombre = "nuevo 33"; articulo.Categoria = 2; articulo.Precio = decimal.Parse("3,5");; showObject (articulo); setValues (articulo, new object[]{ 33L, "nuevo 33 Modificado", 3L, decimal.Parse("33,33")}); }
public static void Main(string[] args) { /* int i = 5; Type tipo = i.GetType(); Console.WriteLine ("type.Name={0} type.FullName={1}",tipo.Name, tipo.FullName); string s = "nombre"; Type tipoString = s.GetType(); // lo mismo: Type tipo = typeof(string) Console.WriteLine (tipoString.Name); object j = 10; Type tipoObject = j.GetType(); */ Articulo articulo = new Articulo (); //muestraTipo (articulo.GetType()); // articulo.Nombre = "nuevo 33"; // articulo.Categoria = 2; // articulo.Precio = decimal.Parse("3,5"); setValues (articulo, new object[] { 33L, "nuevo 33 modificado", 3L, decimal.Parse("33,33") }); muestraObjeto (articulo); }
public static void Main(string[] args) { //PRUEBAS DE TIPOS DE DATOS /*int i=11; Type tipo = i.GetType (); //Console.WriteLine ("tipo.Name={0}, {1}", tipo.Name,tipo.FullName); ES PARA HACER REFERENCIA A LO DE DESOPUES DE LA COMA [0,1,2,3...] showType (tipo); string cadena="Hola skoner"; Type tipo2 = cadena.GetType (); //Console.WriteLine ("tipo2.Name={0}", tipo2.Name); showType (tipo2); Type tipostring = typeof(string); //Console.WriteLine ("tipostring.Name={0}", tipostring.Name); showType (tipostring); Type tipobase = typeof(object); showType (tipobase); Type tipoFoo = typeof(Foo); showType (tipoFoo); Foo foo = new Foo (); //showObject (foo);*/ Articulo articulo = new Articulo (); /*articulo.Nombre="articulo 1"; articulo.Categoria=2; articulo.Precio = decimal.Parse("7.5");*/ setValues (articulo, new object[] { 33L, "nuevo articulo 1", 3L, decimal.Parse("11,11") }); // DEBEN IR EN EL ORDEN PUESTO EN LA CLASE DEL OBJETO showType (articulo.GetType ()); //IGUAL QUE Type tipoFoo = typeof(Foo); showType (tipoFoo); showObject (articulo); }