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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:12:55+00:00 2026-05-11T02:12:55+00:00

I would like to have a function that modifies some variable list of parameters

  • 0

I would like to have a function that modifies some variable list of parameters but they are all value types (int, string). There is a way to make the params keyword work with ref keyword or something close to that?

public void funcParams(params object[] list) {    /* Make something here to change 'a', 'b' and 'c' */ }  public void testParams() {     int a = 1, b = 2, c = 3;      funcParams(a, b, c); } 

The problem is, I’m trying to make my life easier making a method that modifies the object fields. I’m doing some dynamic code generation using Cecil and I’m trying to avoid writing too much IL generated code.

To simplify I would like to pass the list of fields by reference I need to change to a function that changes them instead of changing them by generating the respective IL. Some of the parameters are nullable and make the code generation a little more painful. Making some overload methods instead of params won’t be much useful in this case.

  • 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. 2026-05-11T02:12:55+00:00Added an answer on May 11, 2026 at 2:12 am

    Yes. It is possible.

    However, the resulting code is ‘unsafe’ which makes it unverifiable.

    That may or may not be an issue depending on your requirements.

    In any case, here is the code:

    using System;  namespace unsafeTest {     class MainClass     {         public static void Main(string[] args)         {             Console.WriteLine('Hello World!');             unsafe              {                        int x = 0;                 int y = 0;                 int z = 0;                 bar(&x, &y, &z);                 Console.WriteLine(x);                 Console.WriteLine(y);                 Console.WriteLine(z);             }         }          unsafe static void bar(params int *[] pInts)         {             int i = 0;             foreach (var pInt in pInts)             {                 *pInt = i++;             }         }     } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 89k
  • Answers 89k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try to use source /home/yourname/bin/Screen/multiUserSettings instead. My guess is that… May 11, 2026 at 5:49 pm
  • Editorial Team
    Editorial Team added an answer If it's just for testing you probably don't want to… May 11, 2026 at 5:49 pm
  • Editorial Team
    Editorial Team added an answer Answer this question: Can you secure your webapp against all… May 11, 2026 at 5:49 pm

Related Questions

I'm having some inheritance issues as I've got a group of inter-related abstract classes
In win32, how do I setup a callback mechanism for RichEdit I have not
I have just ported several of our home-made Outlook COM-addins from Delphi 2007 to
I have a bunch of keys that each have an unlikeliness variable. I want

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.