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

  • Home
  • SEARCH
  • 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 104885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:21:07+00:00 2026-05-11T01:21:07+00:00

I was looking at the System.Net Namespace and it has an IPAddress instance you

  • 0

I was looking at the System.Net Namespace and it has an IPAddress instance you can use. This has a Parse method which you can use to parse a string into an IPInstance then use the Address property to give you the long value.

However…

The number returned is NOT the true conversion.

e.g. For IP 58.0.0.0 , the System.Net namespace gives me a value of 58… When in fact, the integer value should be 973078528

Can someone please show me the correct code do convert this?

The formula should be.. (for ip 192.1.20.10).

192 * (256*256*256) + 1 * (256*256) + 20 * (256) + 10

The reason this formula is correct is that the number it returns you can use in a >= and <= query to determine an IP address that falls within a range.

The Address Property (of the IPAddress instance) does not calculate/return this. A bonus point for anyone that knows why the address property does not return what I think is the correct answer…

Other examples from other links did not work either.

  • 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. 2026-05-11T01:21:08+00:00Added an answer on May 11, 2026 at 1:21 am

    This might work, will try it and see.

    public double IPAddressToNumber(string IPaddress)     {         int i;         string [] arrDec;         double num = 0;         if (IPaddress == '')         {             return 0;         }         else         {             arrDec = IPaddress.Split('.');             for(i = arrDec.Length - 1; i >= 0 ; i = i -1)                 {                     num += ((int.Parse(arrDec[i])%256) * Math.Pow(256 ,(3 - i )));                 }             return num;         }     } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been looking into the namespace for System.Net.PeerToPeer in .NET 4.0 and the
I looking for free ASP.NET based content management system (CMS) which has the following
I'm currently looping through a datareader and calling the System.Net.Mail.SmtpClient's Send() method. The problem
I've been looking around the System.Xml namespace, but don't see anything that would support
I am looking for a lightweight source control system for use on hobby projects
We are looking at updating (rewriting) our system which stores information about when people
I am looking to develop a system in which i need to assign every
I'm trying to wrap my head around the use of the System.Transactions namespace in
Looking at System.Collections.Generic.Dictionary<TKey, TValue> , it clearly implements ICollection<KeyValuePair<TKey, TValue>> , but doesn't have
I'm doing a bookmarking system and looking for the fastest (easiest) way to retrieve

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.