In
this article I am going to tell you how we can display all even numbers from 1
to 100 in asp.net using C# and Vb.net.
C#
code:
protected void Page_Load(object
sender, EventArgs e)
{
DispalyEvenNumbers();
}
public void DispalyEvenNumbers()
{
{
if
(i % 2 == 0)
{
Response.Write(i + "<br/>");
}
}
}
VB.net
code:
Protected Sub Page_Load(sender As
Object, e As
System.EventArgs) Handles
Me.Load
DispalyEvenNumbers()
End Sub
Public Sub DispalyEvenNumbers()
For i As Integer = 1 To 100
If
i Mod 2 = 0 Then
Response.Write(i.ToString() + "<br/>")
End
If
Next
End Sub
0 Comments