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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:35:01+00:00 2026-05-13T12:35:01+00:00

Basicly what I would like to is generate Other random values which have not

  • 0

Basicly what I would like to is generate Other random values which have not the same value of the given value.

I somehow can not get hold of the primitive Types in a nice way.

The primitive types are Boolean, Byte, SByte, Int16, UInt16, Int32, UInt32, Int64, UInt64, IntPtr, UIntPtr, Char, Double, and Single.

Here is basicly what I am trying to do.

  int oldValue = 1;
  oldValue.Other(); // 2

  long oldValue = 1;
  oldValue.Other(); // 2

  string oldValue = "1";
  oldValue.Other(); "5"

Has someone suggestions how I could tackle this nicely?

  • 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-13T12:35:02+00:00Added an answer on May 13, 2026 at 12:35 pm

    There is a base class called ValueType. The problem is that you need to cast the value to child when using it.

    e.g

    int a =3;
    int b = (int)a.abc();
    

    extension look like following

    public static class ValueTypeExtension
    {
        public static ValueType abc(this ValueType a) {
    
            return default(ValueType);
        }
    }
    

    you have to perform type check on parameter ‘a’ in if elseif to correctly return the value you intend to.

    e.g

        if( a is Int32 )
          return 4;
    

    Update:
    string is not exactly a value type but its treated like one. You still have to handle string in a seperate extension method.

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

Sidebar

Related Questions

I have defined a ConfigurationProperty class, which is basicly a key-value pair (with key
I have created a custom user control, which is basicly a ItemsControl with it's
I have searched hi and low for a solution for this, basicly I would
I would like to build an Android Quotes App. So basicly an app, in
I would like to know how I can make a webpage that will look
I have 2 array's and would like to merge them together and is the
I would like to have an advice for this issue: I am using Jbos
I would like to have a div act like a strobe light with jquery.
I would like to listen on 2 different UDP port with the same server.
I have a custom datastructure, which can be accessed in multiple ways. I want

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.