Declare and assign multiple string variables at the same time

前端 未结 10 2288
醉话见心
醉话见心 2020-12-08 13:03

I\'m declaring some strings that are empty, so it won\'t throw errors later on.

I\'ve read that this was the proper way:

string Camnr = Klantnr = Ord         


        
10条回答
  •  悲哀的现实
    2020-12-08 13:19

    Fairly old question but incase someone goes back.
    This isn't as compact as the other answers above, but fairly readable and easier to type using Visual Studio Multi-Line selection shortcut [Alt+ Shift + ↑] (or other directions)

    string Camnr = string.Empty;
    string Klantnr = string.Empty;
    

    Type out all variable names on new lines. Multi-Select in front of them an type "string". Multi-Select behind them and type "= string.Empty;".

提交回复
热议问题