Organizing c# code into different files

后端 未结 4 1699
礼貌的吻别
礼貌的吻别 2021-01-14 06:23

I\'ve gotten to a point where my main code file is about a thousand lines long and it\'s getting un-manageable; that is, I\'m starting to get confused and not know where to

4条回答
  •  花落未央
    2021-01-14 06:30

    1. Strip out each decent size class into at least one file. Wrap each class in the same namespace.
    2. For large classes use either:
      a. Region blocks eg

      #region // Members
      int my_int;
      // other members...
      #endregion

      b. partial keyword to break a single class accross several files.

提交回复
热议问题