Using various types in a 'using' statement (C#)

前端 未结 4 2112
陌清茗
陌清茗 2020-12-03 06:48

Since the C# using statement is just a syntactic sugar for try/finally{dispose}, why does it accept multiple objects only if they are of the same type?

4条回答
  •  無奈伤痛
    2020-12-03 07:36

    Other variable declarations in C# only allow you to declare multiple variables of the same type in the same statement; I don't see why using headers should be different.

提交回复
热议问题