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

  • Home
  • SEARCH
  • 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 6748047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:31:07+00:00 2026-05-26T12:31:07+00:00

This is what I’ve got in a project including fairly complex cases of reflection:

  • 0

This is what I’ve got in a project including fairly complex cases of reflection:

static int PopulateValues<T>(List<string> propertyNames, ref T list) { /*...*/ }

// Example call:
PopulateValues(propertyNames, ref list1);

I’d really like to add params along and do params ref T[] lists to allow usage:

PopulateValues(propertyNames, ref list1, ref list2, ...);

However, this gives me the following error:

Parameter cannot have both ‘params’ and ‘ref’ modifiers.

My initial thought was letting list be an object[], but the usage would be ugly (casting object). So for now, I’m calling the method one time for each type, doing unnecessary multiple enumerations.

SOLVED: I don’t need ref for calling reflection methods on parameter class (SetValue, GetValue, InvokeMember etc), which means that I can skip the ref altogether. Really, I should have tried that.

  • 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-26T12:31:08+00:00Added an answer on May 26, 2026 at 12:31 pm

    On ref + params:

    A member can’t be a reference. And since params transforms each parameter into array member this isn’t possible.

    The only thing I can think of is manually creating a number of overloads.


    But in your case I don’t see why you need ref in the first place. To add members to a list you don’t need to change the reference itself, and thus don’t need to pass it my ref in the first place.

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

Sidebar

Related Questions

This is driving me insane! Here's the code: public static void main(String[] strings) {
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This would list numbers 5.0 to 7.0 in a drop select menu: <%= f.select
this gives me an error, Bad Reciever type 'NSIntegar (aka 'int'). NSString *tempTag =
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim
this is what i have so far: type u = {str : string} //some
i got an object with contents of html markup in it, for example: string
Does anyone know how can I replace this 2 symbol below from the string

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.