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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:07:37+00:00 2026-06-09T23:07:37+00:00

I want to refactor some of my code, so I would like to create

  • 0

I want to refactor some of my code, so I would like to create method for few repeating tasks. One of methods, depending on context, include working something with properties. Most of properties are string, but there are also enum and int types.
For example, method should look like this:

private void someMethod (int i, 'here should be property') {
//enter code here
}

So, does anybody know how to pass this properties?

Thanks in advance!

Another explanation. This code should change label properties: text, font… But, label.Text should be changed depending on entry parameter.

it should look like this

private void setLabel (Label label, 'I dont know what goes here to pass a property') {
label.Text = user.'property'.toString();
//some more code
}
  • 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-09T23:07:38+00:00Added an answer on June 9, 2026 at 11:07 pm

    If you don’t have any particular reason why you want to actually pass the property, you can just pass the value of that property:

    private void setLabel (Label label, object propertyValue)
    {
        label.Text = propertyValue.ToString();
    }
    

    And then call it like:

    setLabel(myLabel, user.ThePropertyIWant);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some code that I want to refactor. I have lots of methods
There's some legacy code that I would like to refactor. There is some data
actually i refactor some portion of code. what i want to do is to
I'm doing some work with stats, and want to refactor the following method :
I want to refactor some code using the Windsor IOC/DI framework, but my issue
I have some code i'd like to refactor that uses a C# iterator (ie
I have a method which i'd like to refactor Basically i want to split
I've got some sample code that I'd like to refactor as I need it
I would like to run some unit tests on the method below I am
I am trying to refactor some code in an ASP.Net website and having a

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.