Boxing and Unboxing in String.Format(…) … is the following rationalized?
问题 I was doing some reading regarding boxing/unboxing, and it turns out that if you do an ordinary String.Format() where you have a value type in your list of object[] arguments, it will cause a boxing operation. For instance, if you're trying to print out the value of an integer and do string.Format("My value is {0}",myVal) , it will stick your myVal int in a box and run the ToString function on it. Browsing around, I found this article. It appears you can avoid the boxing penalty simply by