• Puzzle
  • Kata

Puzzle 1: Passing reference types by value (Beginner)

With this post I’ll start a series about programming puzzles and kata’s.

These small exercises will focus on the specific features of C#1,2 & 3.

Have fun…

What is the output of: ValueRef.Problem() ?

Can you explain why?

public class ValueRef

{

        public static void Problem()

        {

            StringBuilder myStrBuilder = new StringBuilder("x");

            AppendHello(myStrBuilder);

            Console.WriteLine(myStrBuilder.ToString());

            Console.ReadLine();

        }



        static void AppendHello(StringBuilder builder)

        {

            builder.Append("hello");

            builder = null;

        }

}