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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:44:32+00:00 2026-05-20T01:44:32+00:00

I have the following code example taken from the code of a Form :

  • 0

I have the following code example taken from the code of a Form:

    protected void SomeMethod()
    {
        SomeOtherMethod(this.OnPaint);
    }

    private void SomeOtherMethod(Action<PaintEventArgs> onPaint)
    {
        onPaint += MyPaint;
    }

    protected void MyPaint(PaintEventArgs e)
    {
        // paint some stuff
    }

The second method (SomeOtherMethod) has resharper complaining at me. It says of onPaint that “Value assigned is not used in any execution path”.

To my mind it was used because I added a method to the list of methods called when a paint was done.

But usually when resharper tells me something like this it is because I am not understanding some part of C#. Like maybe when the param goes out of goes out of scope the item I added to the list gets removed (or something like that).

I thought I would ask here to see if any one knows what resharper is trying to tell me.

(Side Note: I usually just override OnPaint. But I am trying to get OnPaint to call a method in another class. I don’t want to expose that method publicly so I thought I would pass in the OnPaint group and add to it.)

  • 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-20T01:44:33+00:00Added an answer on May 20, 2026 at 1:44 am

    The warning is correct. Consider the following:

    int X;
    int Y;
    void SomeMethod()
    {         
        SomeOtherMethod(this.X);
    }      
    void SomeOtherMethod(int x)
    {
        x += this.Y;
    }
    

    Here the code modifies formal parameter x, and then never uses the modified x. This does not modify “this.X”

    You’ve done the same thing with the delegate. You modify the formal parameter and then never use the result; the original “OnPaint” is unchanged, just as “X” is unchanged in my example.

    Remember, just because a delegate is a reference type does not mean that you’re passing around a reference to a variable when you pass around an instance. You’re passing a reference to an instance, not a reference to the storage location of that instance.

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

Sidebar

Related Questions

I have the following code taken from cplusplus.com : // set_terminate example #include <iostream>
I have the following code (taken from actual script): $result=mysql_query($sql); while($row=mysql_fetch_assoc($result)) { $auth_token=$row['oauth_token']; $auth_token_secret=$row['oauth_token_secret'];
I have the following example code: class A(object): def __init__(self, id): self.myid = id
I have the following code: $bind = new COM(LDAP://CN=GroupName,OU=Groups,OU=Division,DC=company,DC=local); When I execute it from
I have the following code: SELECT <column>, count(*) FROM <table> GROUP BY <column> HAVING
Following this example in the Java(tm) tutorials, I have implemented this basic one producer
I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public
I have following Code Block Which I tried to optimize in the Optimized section
I'm trying to use opengl in C#. I have following code which fails with
I have the following code in a web.config file of the default IIS site.

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.