Reputation: 233
Hey I am making a String but some of thevariables are going to be empty and I want these to be skipped but not sure how to go about this. Here is the code for the string below.
Dim TenantList As String = Ten11 & "," & Ten10 & "," & Ten9 & "," & Ten8 & "," & Ten7 & "," & Ten6 & "," & Ten5 & "," & Ten4 & "," & Ten3 & "," & Ten2 & "," & Ten1
Upvotes: 0
Views: 38
Reputation: 460288
You can put them in a collection and use String.Join
:
Dim allStrings As String() = {Ten11, Ten12, Ten13, Ten14, ...}
Dim notEmpty = From str In allStrings Where Not String.IsNullOrEmpty(str)
Dim TenantList As String = String.Join(",", notEmpty)
I'm using LINQ to filter out the empty strings, so you need Imports System.Linq
.
Upvotes: 3