Why use TagBuilder instead of StringBuilder?

后端 未结 6 1909
-上瘾入骨i
-上瘾入骨i 2020-12-13 18:04

what\'s the difference in using tag builder and string builder to create a table in a htmlhelper class, or using the HtmlTable?

aren\'t they generating the same thin

6条回答
  •  暖寄归人
    2020-12-13 18:28

    aren't they generating the same thing??

    Well, sure, but that shouldn't be a deterrent, should it? One class is designed for something more specific than the other, so it offers a greater level of convenience.

    I could ask: why use a StringBuilder? Why not a List? Couldn't I generate the same thing from either?

    Going one step further: why even a List? Why not just a char[], the resizing/manipulation of which I can control myself? I can still totally create a string from a char[].

    In fact, all I really need is a char* and an int (for length). Right?

    My point is just that if a class is available for specialized functionality that you can use, it makes sense to use it if you ask me.

提交回复
热议问题