You can do it using either a string or a StringBuilder, but a string is a lot less efficient because each time you add new data to it, it creates a new string and returns that - the old string is untouched (because strings are
immutable
- the cannot be changed once they are created). StringBuilders are different - they can be changed, until they run out of space, at which point they are replaced with a bigger one. That is why it is considered a bad idea to use a string for this kind of operation.
If you do use a string, then you need a different syntax:
strHtml = strHtml + "new string";
or
strHtml += "new string";
The string class does not have an Append method.
If you use a StringBuilder, you do not need the
ref
parameter - you do if you want to "change" the string.
Personally, I would ditch the
ref
parameter, use a StringBuilder and return it as the result of the method anyway:
public StringBuilder Paging(StringBuilder strHtml, int pageIndex, int pagingCount, int rowCount, string listView, string controller, int position)
{
strHtml.Append("<table class="Dsply" border="0" cellspacing="0" cellpadding="0"><tr><th>");
return strHtml;
}</th></tr></table>