Properly exposing a List?

前端 未结 8 1551
谎友^
谎友^ 2021-02-02 01:20

I know I shouldn\'t be exposing a List in a property, but I wonder what the proper way to do it is? For example, doing this:

public static          


        
8条回答
  •  长情又很酷
    2021-02-02 01:47

    If the class has no other purpose you could inherit from list and override the add method and have it throw an exception.

提交回复
热议问题