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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:12:24+00:00 2026-05-29T06:12:24+00:00

For some reason when I run the test method, I am getting a false

  • 0

For some reason when I run the “test” method, I am getting a false result. I used some of the code from my other question about random number generation, which I have confirmed does work, but with additional safety checks.

public class strUtls
{
    public void test()
    {
        var maybe = 40000000f * 40000000f;
        bool number = isNumber(maybe);
    }

    public bool isNumber(object O)
    {
        // INT16,INT32,INT64,DOUBLE,FLOAT
        if (upper(O.GetType().ToString()).Contains("INT") || upper(O.GetType().ToString()).Contains("DOUBLE") || upper(O.GetType().ToString()).Contains("FLOAT"))
        {
            return true;
        }
        else
        {
            return false;
        }
    }

    private string upper(string s)
    {
        try
        {
            for (int i = 0; i < s.Length; i++)
            {
                s = s.Replace(s[i], upper(s[i]));
            }

            return s;
        }
        catch (IndexOutOfRangeException)
        {
            return s;
        }
    }

    private char upper(char S)
    {
        switch (s)
        {
            case ('a'):
                return 'A';
                break;
            case ('b'):
                return 'B';
                break;
            case ('c'):
                return 'C';
                break;
            case ('d'):
                return 'D';
                break;
            case ('e'):
                return 'E';
                break;
            case ('f'):
                return 'F';
                break;
            case ('g'):
                return 'G';
                break;
            case ('h'):
                return 'H';
                break;
            case ('i'):
                return 'I';
                break;
            case ('j'):
                return 'J';
                break;
            case ('k'):
                return 'K';
                break;
            case ('l'):
                return 'L';
                break;
            case ('m'):
                return 'M';
                break;
            case ('n'):
                return 'N';
                break;
            case ('p'):
                return 'O';
                break;
            case ('o'):
                return 'P';
                break;
            case ('q'):
                return 'Q';
                break;
            case ('r'):
                return 'R';
                break;
            case ('s'):
                return S;
                break;
            case ('t'):
                return 'T';
                break;
            case ('u'):
                return 'U';
                break;
            case ('v'):
                return 'V';
                break;
            case ('w'):
                return 'W';
                break;
            case ('x'):
                return 'X';
                break;
            case ('y'):
                return 'Y';
                break;
            case ('z'):
                return 'Z';
                break;
            default:
                return s;
                break;
        }
    }
}
  • 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-29T06:12:24+00:00Added an answer on May 29, 2026 at 6:12 am

    Simplifying the madness a little, The easiest way to find your answer is to examine the contents of the string. Others have already outlined the correct approach now. I’m just posting this to give you an idea of a better way to structure the same code. String already has a ToUpper() Method, by the way.

    class Program
    {
        static void Main(string[] args)
        {
            var maybe = 40000000f * 40000000f;
            Console.WriteLine(isNumber(maybe));
            Console.ReadLine();
        }
    
        public static bool isNumber(object O)
        {
            var s = O.GetType().ToString().ToUpper();
            Console.WriteLine(s); // prints "SINGLE"
            // this is silly
            //return (s.Contains("INT") || s.Contains("DOUBLE") || s.Contains("SINGLE"));
            // better
            return O is int || O is Int64 || O is float || O is double; // etc.
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use Python to run pdftotext, but for some reason, my code
For some reason in the testEmployee method I am getting weird error messages saying
For some reason I'm having trouble getting my program to run a while loop.
For some reason, nothing happens when I run this macro. What might I be
For some reason, Section 1 works but Section 2 does not. When run in
For some reason, when using two sums on a group by, i run into
For some reason, addAsync chaining in a flexunit test as described in this article
I'm having trouble getting forwardInvocation to work. For some reason, the Objective-C runtime completely
For some reason when I run bundle install it installs to production: Your bundle
I have a unit test which depends on some code that uses MEF. When

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.