public void CastingToMoreSpecificExample() { var something = new SpecificType(); //Here is an example of implicit conversion, since it wants an object a SpecificType is being coerced to be an object var thing = new CastingOrCoercingTypes().GetThing(something); Assert.Equal(something.Thing, thing); }
public void IncrementInt_GeneralReturned() { var number = 1; //Look at how easy that was to call the increment method and have coerced right into a general type var incrementedGeneral = new CastingOrCoercingTypes().Increment(number); Assert.Equal(typeof(GeneralType), incrementedGeneral.GetType()); }