Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

The compiler will report an error on the call to the Swap() function. Why?

0
Posted

The compiler will report an error on the call to the Swap() function. Why?

0

public static void Swap(ref object a, ref object b) { a = 5; b = “Hello”; } If the compiler allowed this code, it would mean assigning a boxed int to a Dog object, which is clearly not type safe.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123