Let’s say you have a generic list:
(VB.Net)
Dim ProdList As New List(Of String)
With ProdList
.Add("Alice Mutton")
.Add("Chai")
.Add("Chang")
.Add("Gravad lax")
End With
(C#)
List ProdList = new List(Of, String);
ProdList.Add("Alice Mutton");
ProdList.Add("Chai");
ProdList.Add("Chang");
ProdList.Add("Gravad lax");
Then, let’s say you want to loop through those items, one at a time and manipulate each one in some manner or form. It’s pretty easy, as you will see.
All you need to do is to put a for each loop around your manipulation code:
(VB.Net)
For Each sItem As String In ProdList
If sItem = (whatever) Then
' do your manipulation here
End If
Next
(C#)
foreach (string sItem in ProdList) {
if ((sItem == whatever)) {
// do your manipulation here
}
}
All Things DotNet Discussed – Winforms/ASP.Net/SharePoint/WPF
Leave a reply
You must be logged in to post a comment.