Make a shortcut for Console.WriteLine()

前端 未结 14 1456
北恋
北恋 2020-12-23 19:55

I have to type Console.WriteLine() many times in my code. Is it possible to create a shortcut for Console.WriteLine so that I can use it like...

CW=Console.Wr         


        
14条回答
  •  心在旅途
    2020-12-23 20:25

    You could no doubt create a Visual Studio snippet for it (although actually there's one already for cw, apparently - try it!).

    I would personally suggest that you don't use a shortcut within the code - it's likely to be clearer to anyone reading it if it still says Console.WriteLine.

    Depending on what this is for, it may make sense to write a helper method called, say, Log - that has a reasonable meaning, whereas CW doesn't.

    (If this is for logging, consider using something more powerful such as log4net, too.)

提交回复
热议问题