Vb.net break statement foreach loop example.
Imports System
Namespace Csharp.BreakStatement
Class Program
Private Shared Sub Main(args As String())
Dim arrString As String() = New String() {"First", "Second", "Third", "Fourth"}
For Each s As String In arrString
If s = "Third" Then
Exit For
Else
Console.WriteLine(s)
End If
Next
Console.WriteLine()
End Sub
End Class
End Namespace

C# break for loop

Here are C# and Vb.net break statement using for loop example. At the end of this post you can see the output of all programs.

VB.net break statement using for loop example.
Imports System
Namespace Csharp.BreakStatement
Class Program
Private Shared Sub Main(args As String())
Dim arrString As String() = New String() {"First", "Second", "Third", "Fourth"}
For i As Integer = 0 To arrString.Length - 1
If arrString(i) = "Third" Then
Exit For
Else
Console.WriteLine(arrString(i))
End If
Next
Console.ReadLine()
End Sub
End Class
End Namespace

Output
First
Second

Description

As you can see the output of above programs. The loop breaks on the occurrence of condition.

Tags:

I'm Satalaj More02/09/2012 11:30

Related posts

C# For Loop
Unlike other programming languages [C#,Vb.net] also supports for—loop. Here we will see syntax, example of break and continue looping scenarios. (V...C# foreach loop
C# foreach loop was first introduced in dot net programming languages. Later it's copied in other programming languages like Java. Here we will see e...c# string1. C# String
2. C# string array
3. c# string whitespaces
4. c# string immutable mutable
Done 5. c# string split
6. c# ConvertTostring()
7. c# string Rep...C# XML XmlReader To Read XML in C# or VB.net we need to use System.XML namespace. Here we will see how to read XML stored at C:\ drive using C#.net and VB.net. Every devel...c# arraylistc# arraylist example
c# foreach arraylist
c# arraylist class
c# arraylist count
c# collection classes
C# arraylist contains
string arraylistC# DateTime Difference
How to get Difference between two dates? Lets see how to do it using [C#] and Vb.net.
We will use Time Span to get difference.
[C#] program to get...C# while loopC# while-loop example demonstrates the usage and it's performance. You can also see why to avoid infinite loops and impact on CPU utilization.C# Binary To StringThis will help you to convert binary to base64,base64 string,c# binary to string,c# binary to ascii,binary byte,c# binary to base64,convert c#

Category list

Author

My name is Satalaj,
but people call me Sat.
Here is my homepage:
www.revenmerchantservices.com.
I live in
Pune, PN and work as a Software Engineer. I'm former MVP in ASP.net year 2010.

Disclaimer: Views or opinion expressed here are my personal research and it has nothing to do with my employer.
You are free to use the code, ideas/hints in your projects. However, you should not copy and paste my original content
to other web sites. Feel free to copy or extend the code.