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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:44:30+00:00 2026-05-13T14:44:30+00:00

I am attempting to store a variable length number that can have leading zeros

  • 0

I am attempting to store a variable length number that can have leading zeros as a part of that number.

Is there a class in the .NET framework capable of storing values like this without losing information about leading zeros, and could surpass the upper limit of a long?

I am currently storing them in a class like this, is there any way I could write this class better in the event there isn’t some struct or class available in the BCL:

[Serializable]
public class Number
{
    public int[] Array { get; set; }
    public int Length { get { return Array.Length; } }

    public Number(string number)
    {
        Array = new int[number.Length];

        for (int i = 0; i < number.Length; i++)
        {
            Array[i] = Convert.ToInt32(number[i].ToString());
        }
    }

    public Number(int[] array)
    {
        Array = array;
    }

    public int ToInt()
    {
        return Convert.ToInt32(ToString());
    }

    public override string ToString()
    {
        StringBuilder sb = new StringBuilder(Array.Length);

        foreach (int i in Array)
            sb.Append(i);

        return sb.ToString();
    }
}

The ability to use this as a struct would be very useful, as would the ability to check equality easily.

Items in bold/italic are the requirements of such a class.

  • 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-13T14:44:30+00:00Added an answer on May 13, 2026 at 2:44 pm

    I’d suggest taking a look at this question about big integers in C#. You could expand them for the leading zeros issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to store the number of rows in a uitable into a variable
I am attempting to store the date in a variable using getdate(). What am
I'm attempting to store the value 0.9999 into an mpfr_t variable using the mpfr_set_str()
I'm in a thread. I have an address. Is that address from a variable
I'm attempting to test that my service is calling Anemone.crawl correctly. I have the
I am attempting to store objects derived from a templated base class in an
Attempting to print out a list of values from 2 different variables that are
Within an SSIS package I have a dataflow that extracts two coloumns from an
I am currently working on an advanced web application that contains a number of
Code snippet to follow. I have a struct (example code has class, tried both,

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.