In C#, how do I keep certain method calls out of the codebase entirely?

后端 未结 6 1043
迷失自我
迷失自我 2021-01-01 23:54

I\'m trying to get rid of all DateTime.Now method calls and replace them with my own GetNow() method, which may sometimes return a fixed date for t

6条回答
  •  执笔经年
    2021-01-02 00:40

    I don't think that this is possible. What you are actually trying to do is override DateTime's struct functionality.

    The only way I can think of is just to go with a custom class that will wrap common functionality of DateTime and offer different functionality on demand...

提交回复
热议问题