public void ImplicitConversionUsingImplicitKeyword() { var oneSpecialInt = new SpecialInt(123); // Implicit conversion to an integer int implicitInt = oneSpecialInt; // Implicit conversion to a SpecialInt SpecialInt anotherSpecialInt = implicitInt; var firstTest = implicitInt + oneSpecialInt; var secondTest = anotherSpecialInt + implicitInt; Assert.AreEqual(typeof(FILL_ME_IN), firstTest.GetType(), "An int and a user-defined type that can return an int walk into a bar... And their baby is a..."); Assert.AreEqual(typeof(FILL_ME_IN), secondTest.GetType(), "This will show you the type is not based on the order of expression's operands, but their result."); }
public void ImplicitConversionUsingImplicitKeyword() { var oneSpecialInt = new SpecialInt(123); // Conversió implícita a integer int implicitInt = oneSpecialInt; // Conversió implícita a SpecialInt SpecialInt anotherSpecialInt = implicitInt; var firstTest = implicitInt + oneSpecialInt; var secondTest = anotherSpecialInt + implicitInt; //Assert.AreEqual(typeof(FILL_ME_IN), firstTest.GetType(), "Un int i un tipus definit per l'usuari que pot retornar un int entren en un bar... El seu bebé és un..."); //Assert.AreEqual(typeof(FILL_ME_IN), secondTest.GetType(), "Això us mostrarà que el tipus no es basa en l'ordre dels operands de l'expressió, sinó en el seu resultat."); Assert.AreEqual(typeof(int), firstTest.GetType(), "Un int i un tipus definit per l'usuari que pot retornar un int entren en un bar... El seu bebé és un..."); Assert.AreEqual(typeof(int), secondTest.GetType(), "Això us mostrarà que el tipus no es basa en l'ordre dels operands de l'expressió, sinó en el seu resultat."); }
public void ImplicitConversionUsingImplicitKeyword() { var oneSpecialInt = new SpecialInt (123); // Implicit conversion to an integer int implicitInt = oneSpecialInt; // Implicit conversion to a SpecialInt SpecialInt anotherSpecialInt = implicitInt; var firstTest = implicitInt + oneSpecialInt; var secondTest = anotherSpecialInt + implicitInt; Assert.AreEqual (typeof(int), firstTest.GetType (), "An int and a user-defined type that can return an int walk into a bar... And their baby is a..."); Assert.AreEqual (typeof(int), secondTest.GetType (), "This will show you the type is not based on the order of expression's operands, but their result."); }