TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Jay Lopez
NA
4
5.5k
how to handle an IndexOutOfRangeException in C#
Sep 21 2016 12:14 AM
using System;
namespace Project1
{
class Project1
{
//Main method begins execution of C# app
static void Main(string[] args)
{
int number;//declare number variable
int[] numberDigits = new int[5];//declare array with 5 digits
int i = 4;//counter
//prompt user and reads number
Console.Write("Enter five digit integer:");
number = Convert.ToInt32(Console.ReadLine());
while(number > 0)
{
int digit = number % 10; //extract last digit
numberDigits[i] = digit;
number = number / 10;//divide by 10 to extract next digit
i--;
}
foreach (int digit in numberDigits) Console.Write("{0} ", digit);
Console.WriteLine();
Console.ReadKey();
}
}
}
Reply
Answers (
6
)
How to varbinary convert in string for mvc
List View Like Android application in C#