Private nested static class - Good or bad practice?

后端 未结 6 581
[愿得一人]
[愿得一人] 2021-01-04 03:20

Would it be considered a bad practice to nest a private static class inside of a non-static class?

public class Outer
{
    private static class Inner
    {
         


        
6条回答
  •  無奈伤痛
    2021-01-04 03:45

    If the class is used in a multi-threaded application, you may need to control access to the static state via locking. That's a problem with static state whether privately nested or not.

提交回复
热议问题