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 9014205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:27:13+00:00 2026-06-16T03:27:13+00:00

I need to split an input value high/low that might come in three different

  • 0

I need to split an input value high/low that might come in three different forms: 120/50, 120/, /50, 120.

I would like to split this into two different variables and check the values I got.

var high = input.Split('/').First();
var low = input.Split('/').Last();

if (high.Length > 0) //Do this
if (low.Length > 0) //Do that  

The problem is that with the two last inputs I get the same value in both high and low. Which means I can’t tell if I got a high value or a low.

I’m starting to suspect I can’t use split here?

EDIT
It seems as if there are values with no / at all. Those values should be interpreted as high values.

  • 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-06-16T03:27:14+00:00Added an answer on June 16, 2026 at 3:27 am

    You could use Nullables and TryParse which is safer:

    string[] parts = input.Split('/');
    int? high = null;
    int? low = null;
    int hightest, lowtest;
    if(int.TryParse(parts[0], out hightest))
        high = hightest;
    if(int.TryParse(parts[1], out lowtest))
        low = lowtest;
    

    Now you can check if they are set with the HasValue property, for example:

    if(high.HasValue)
    {
        int val = high.Value;
        // do something with it
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have many different formats of input strings, and I need to split the
I have a problem where I need to split an input string into possible
I need to split my string input into an array at the commas. Is
i need to split and print the date value of a record and i
I need to split ABAP date like 20091101 --> "01", "november", "2009" The "01"
i have this line: Dim strings_extreme = input.Split(,c).Distinct().OrderBy(Function(s) s) i need to Dim it
Need to split a string which is a combination of different materials. Need to
I need to split the following XML file based on a predetermined value, for
I need to use regex in C# to split up something like 21A244 where
I need to parse an input for each value. Input size is not static

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.