c# - Are methods faster when parameters are referenced? -


this question has answer here:

sometimes, got helper methods like:

private string generatereport(string doc, list<string> sheets, blah blahblah) {     //dostuff() } 

seeing lot of in code makes me wonder if i'm messing computer memory - throwing parameters , fro. on basic level, problem solved having class level variables in cases, may deriving class or using helper method class. question is:

is using references preferable option? i.e.

private string generatereport(ref string doc, ref list<string> sheets, ref blah blahblah) {     //dostuff() } 

and when should not use (if applicable)?

thanks.

the direct answer no. please see question , answer: which faster? byval or byref?

also remember passing reference should foremost design choice. passing reference states changes made parameters directly influence variables supplied. should used if want return more 1 parameter of if looking above behavior specifically.

and finally, if code not processing heavy should not focus on making small performance improvements rather focus on readability , stability.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -