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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:51:22+00:00 2026-05-24T10:51:22+00:00

I have this code : CreaPager(m_oPacchettiEnum, 1, 10); private void CreaPager(IEnumerable enPass, int limiteUp,

  • 0

I have this code :

CreaPager(m_oPacchettiEnum, 1, 10);

private void CreaPager(IEnumerable enPass, int limiteUp, int limiteDown)
{
    enPass= enPass.Skip(limiteDown).Take(limiteUp);
}

and I’d like, when I edit enPass, reflect the edit to m_oPacchettiEnum, without have a return IEnumerable<T> function.

So, edit directly m_oPacchettiEnum trought the function. I use to do it on C, don’t know if is possible on C# (but I think so).

I read somethings about using out, but seems that it doesnt work :

CreaPager(out m_oPacchettiEnum, 1, 10);

private void CreaPager(out IEnumerable enPass, int limiteUp, int limiteDown)
{
    enPass= enPass.Skip(limiteDown).Take(limiteUp);
}
  • 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-24T10:51:23+00:00Added an answer on May 24, 2026 at 10:51 am

    out doesn’t work here because you can’t use an out parameter in the method until it’s been assigned. Since your assignment uses enum (which you should rename) as part of the right-hand-side, it’s not allowed. Switching out to ref will make things work.

    However. As I mentioned in my answer to your previous (now deleted) question, please don’t do this. It is much more idiomatic when working with sequences to return a new IEnumerable<T>:

    var newQuery = CreaPager(m_oPacchettiEnum, 1, 10);
    
    private void CreaPager<T>(IEnumerable<T> enumeration, int limiteUp, int limiteDown)
    {
        return enumeration.Skip(limiteDown).Take(limiteUp);
    }
    

    As well, you can make the method an extension method by preceding the first parameter with this:

    private void CreaPager<T>(this IEnumerable<T> enumeration, int limiteUp, int limiteDown) { .. }
    

    Doing so would allow you to integrate your method into a LINQ-to-Objects call chain:

    var query = myEnumerable.Where(x => x.OtherProp == 1).CreaPager(1, 10).Select(x => x.SomeProp);
    

    EDIT: Since you need to also return a string, make that the out parameter:

    private void CreaPager<T>(this IEnumerable<T> enumeration, int limiteUp, int limiteDown, out string myString)
    {
        myString = "foo";
        return enumeration.Skip(limiteDown).Take(limiteUp);
    }
    

    You’d call the method like this:

    string theString;
    var newQuery = CreaPager(m_oPacchettiEnum, 1, 10, out theString);
    

    out is fine here, since I’m assuming you don’t need to both use and assign the string. And if you do, then I would suggest you split it into two parameters anyway.

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

Sidebar

Related Questions

I have this code private void writeReport(IReport report, string reportName) { string reportString =
I have this code, that draws an image. private void timer1_Tick(object sender, EventArgs e)
i have this code which doesnt work: void CAnalyzerIF::SetData(int i_iIters, const CParameterSet* i_CParameterSet) {
I have this code: foreach(int i in Directions) { if (IsDowner(i)) { while (IsDowner(i))
I have this code: - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { mouseSwiped = NO; UITouch
I have this code: - (void)viewDidLoad { [super viewDidLoad]; NSArray *image = [NSArray arrayWithObjects:[UIImage
I have this code #include <iostream> using namespace std; int main(int argc,char **argv) {
I have this code for doing an ajax request to a webservice: var MyCode
I have this code: $(div[id^='intCell']).mouseover(function() { $(this).css({ border:,1px solid #ff097c}); }).mouseout(function() { $(this).css({border:,1px solid
I have this code to show a map using the Virtual Earth API: <script

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.