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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:31:39+00:00 2026-05-16T02:31:39+00:00

In .NET the Integer Parse methods are useful for converting a string to an

  • 0

In .NET the Integer Parse methods are useful for converting a string to an int, but the string must be a valid integer without any extra characters. Is there a function that will convert the integer portion of a string to an int and ignore everything else in the input string?

I’m looking for something like this:

int x = ConvertFunction("1A"); // x should equal 1 instead of throwing an error

I guess I could use RegEx to extract the digits from the beginning of the string, but before I roll my own, I wanted to see if something like this already existed. It seems like I’ve used a language at one time or another that had this type of conversion function, but I can’t find it in .NET.

  • 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-16T02:31:40+00:00Added an answer on May 16, 2026 at 2:31 am

    As Raj mentioned use regex.

    Pseudocode:

    r = Regex("[0-9]+") //Or more complex if you want other numbers
    foreach m in r.Matches(InputString)
        number = int.Parse(m)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 502k
  • Answers 502k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try putting it all in the main selector: Example: http://jsfiddle.net/8Tkex/… May 16, 2026 at 2:40 pm
  • Editorial Team
    Editorial Team added an answer You don't say how you're using Jackson in Spring, so… May 16, 2026 at 2:40 pm
  • Editorial Team
    Editorial Team added an answer According to man fork child's signal handlers are inherited from… May 16, 2026 at 2:40 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I need to parse a decimal integer that appears at the start of a
Below is an article about .net framework's use of patterns. I'm not sure I
I was looking at the System.Net Namespace and it has an IPAddress instance you
What .NET method has this error message: Object cannot be cast from DBNull to
I need to convert an integer into a base64-character representation. I'm using OxA3's answer
In .NET, regex is not organizing captures as I would expect. (I won't call
What are the differences between 32 and 64-bit .NET (4) applications? Often 32-bit applications
I'm trying to get a VB.net (express 2010) app to connect to a socket
Ok obviously I am fighting .net here ... and the answer is probably that
I'm using open source component to retrieve emails from my mail server using vb.net

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.