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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:46:47+00:00 2026-06-09T18:46:47+00:00

I want to, for example, add a method to integer (i.e., Int32 ), which

  • 0

I want to, for example, add a method to integer (i.e., Int32), which will make me able to do the following:

int myInt = 32;
myInt.HelloWorld();

One can say, instead of insisting doing the above, you can write a method which takes an integer, HelloWorld(integer), like the following, more easily:

int myInt = 32;
HelloWorld(myInt);

However, I’m just curious whether it’s possible or not. If true, is that a good programming practice to add some other functionality to well known classes?

PS: I tried to make another class which inherits from Int32, but cannot derive from sealed type ‘int’.

  • 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-06-09T18:46:48+00:00Added an answer on June 9, 2026 at 6:46 pm

    You can add an extension method for int32.

       public static class Int32Extensions
       {
           public static void HelloWorld(this int value) 
           {
             // do something
           }
       }
    

    Just remember to using the namespace the class is in.

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

Sidebar

Related Questions

For example, if I want to add this method: @Override protected void onActivityResult(int requestCode,
I want to add code php to variable with html, for example $html =
I want to add space after every two chars in a string. For example:
for example, I want to add this to jsfiddle.net jQuery Validation is this possible?
I want to add a new tab page for every newly opened form. Example:
I want to write a method that when supplied an array of ints will
Suppose I would like to add a method to Scanner called nextPositiveInt() which is
I don't think this is possible but here goes... I want to add method
I'm implementing XMLRPCServer following Standard Python Library by Example . I want client to
<div id=example style=background:yellow;height:200px;width:200px;> <button>Some text</button> </div>​ I want #example to .hide when it's clicked,

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.