VB.NET ASP.NET中更好的短代码 [英] Better shorter code in VB.NET ASP.NET

查看:117
本文介绍了VB.NET ASP.NET中更好的短代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个代码。我看着它但不确定它是最好的。我正在加入地址线,摆脱空白。有没有人有任何想法来改善这个?谢谢!



I have this code. I look at it but not sure its the best. I'm joining address lines, getting rid of blanks. Has anybody got any ideas to improve this? Thanks!

                If A2 <> "" Then A2 = ", " & A2
                If A3 <> "" Then A3 = ", " & A3
                If A4 <> "" Then A4 = ", " & A4
                If A5 <> "" Then A5 = ", " & A5
                If A6 <> "" Then A6 = ", " & A6
                If A7 <> "" Then A7 = ", " & A7
Dim Line1 As String = A2 & A3 & A4 & A5 & A6 & A7





我尝试过:



还没有,没有想法! Stringbuilder?



What I have tried:

Nothing yet, short of ideas! Stringbuilder?

推荐答案

这是我在谷歌发现的: .net - 忽略空字符串的String.Join方法? - 堆栈溢出 [ ^ ]。祝你好运。
This I found with Google: .net - String.Join method that ignores empty strings? - Stack Overflow[^]. Good luck.


这篇关于VB.NET ASP.NET中更好的短代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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