Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How slow is passing large strings as return values in C#?

Tags:

string

c#

I want to know how return values for strings works for strings in C#. In one of my functions, I generate html code and the string is really huge, I then return it from the function, and then insert it into the page. But I want to know should I pass a huge string as a return value, or just insert it into the page from the same function?

When C# returns a string, does it create a new string from the old one, and return that?

Thanks.

like image 568
omega Avatar asked Nov 27 '22 09:11

omega


1 Answers

Strings (or any other reference type) are not copied when returning from a function, only value types are.

like image 66
CSJ Avatar answered Dec 03 '22 12:12

CSJ