c# - If a method performs operations on a reference type is there any need to return it? -


If I have a method that operates especially on a reference type variable (such as a dataset) and modifies it , Then there is no need to return that variable to the method ??

For example, the following method goes through a data and trim all the values ​​within it and then returns the dataat to the caller:

  private datatyll TrimAladataDataTable (Datatelle DT) {foreach (Detroit Row in dt.Rows) {foreach (Datacolumn DC in dt.Columns) {Line [DC] = Line [DC] .Ostring () Trim (); }} Return DT; }  

Would it be better if this method is devoid of zero? This (?) Seems very nonsensical to return, but do you think it reads better if it returns the item after operating it (as it does at this time) ??

For me, when a method returns a reference type, then I hope it is a new one Be an object. I decide to withdraw it from zero.

One question: Is there any reason for this method not to be a member of the DataTable class? I think that DataTable.TrimAllData () will also work better


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -