在 Visual Basic 中使用冒号将两条语句放在同一行 [英] Using colons to put two statements on the same line in Visual Basic

查看:17
本文介绍了在 Visual Basic 中使用冒号将两条语句放在同一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Visual Basic 中使用冒号将两条语句放在同一行是否被认为是不好的做法?

Is it considered bad practice to use colons to put two statements on the same line in Visual Basic?

推荐答案

使用冒号来组合语句本身并没有错.这实际上取决于上下文,但只要它不降低可读性,就没有任何问题.

There is nothing inherently wrong with using the colon to combine statements. It really depends on the context but as long as it doesn't reduce readability, there is nothing wrong with it.

作为一般规则,我避免为此使用冒号.我发现每行有一个语句更具可读性.然而,这不是一个特定于冒号的问题.我避免在 C# 或 C++ 中对分号做同样的事情.这只是个人喜好.

As a general rule I avoid using the colon for this purpose. I find it's more readable to have one statement per line. However this is not a colon specific issue. I avoid doing the same with a semi-colon in C# or C++. It's just a personal preference.

这篇关于在 Visual Basic 中使用冒号将两条语句放在同一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆