Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7666623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:52:48+00:00 2026-05-31T14:52:48+00:00

I Have a string array with 5 values, i want the program to loop

  • 0

I Have a string array with 5 values, i want the program to loop even though i don’t enter a value for the arrays. If I split the arrays without inserting anything (pressing ….. (5 times “.” to split the array) then it doesn’t crash it will just loop. But if i just hit enter, then the program crashes.

Is there a way to fix the loop so that even though there is no kind of input, that it won’t crash? (It also crashes if you don’t complete all 5 values.)

Net = Console.ReadLine();
            string[] oktet = new string[5]; 
            oktet = Net.Split('.', '/'); 

            temp = oktet[0]; //inputs value of array in temp
            NaN = int.TryParse(temp, out Net0);
            temp = oktet[1];
            NaN = int.TryParse(temp, out Net1);
            temp = oktet[2];
            NaN = int.TryParse(temp, out Net2);
            temp = oktet[3];
            NaN = int.TryParse(temp, out Net3);
            temp = oktet[4];
            NaN = int.TryParse(temp, out subnet);
        }
        while (!NaN | Net0 > 255 | Net0 < 0 | Net1 > 255 | Net1 < 0 | Net2 > 255 | Net2 < 0 | Net3 > 255 | Net3 < 0 | subnet > 32 | subnet < 0);

I know it’s pretty amateur, but hey, we’re here to learn right? 🙂

Thanks in advanced!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T14:52:49+00:00Added an answer on May 31, 2026 at 2:52 pm

    You can try to do something like this:

    string[] oktet = Net.Split('.', '/'); // size array according to input
    
    if (oktet.Length != 5) continue; // reloop on bad input
    

    Those two lines of code replace these:

            string[] oktet = new string[5]; 
            oktet = Net.Split('.', '/'); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my Values folder for my project, I have a string array named currency_avatar.
Say I have an array of values: string[] text = new string[] { val1,
I have this 4 Dimensional array to store String values which are used to
I have array of strings, String[] data and it's 10 elements has value P
I have an array of some data type (int, string, or even user defined
I have an array defined in my strings.xml file names. I want the values
I have an array of values that I want to pass in as a
I have a string array in C# and I intend to copy it in
I have a string array: string[] authors = new string[3]; authors[0] = Charles Dickens;
I have a string array in C named args[] - now how can I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.