c# toString() performance
问题 I'm curious about the ToString() method in C#. Take for example the following: object height = 10; string heightStr = height.ToString(); When I call ToString() on height , I get a string type back. Is the runtime allocating memory for this string? 回答1: Yes, the runtime is going to allocate memory for any string object that you create or request, including one that is returned from a method call. But no, this is absolutely not something that you have to worry about. It will not have any