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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:09:50+00:00 2026-06-17T20:09:50+00:00

I used the same TextChanged event handler for 2 textboxs so Is their any

  • 0

I used the same TextChanged event handler for 2 textboxs so Is their any performance improvement or it is just matter of readability?

Method 1

private void txtcode_TextChanged(object sender, EventArgs e)
        {
        //Some code
        }
private void txtname_TextChanged(object sender, EventArgs e)
        {
        //Some code
        }

Method 2

private void txt_TextChanged(object sender, EventArgs e)
    {
        TextBox txtbx = (TextBox)sender;
        switch (txtbx.Name)
        {
            case "txtname":
                //Some code
                break;

            case "txtcode":
                //Some code
                break;

            default:
                break;
        }

    }
  • 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-17T20:09:52+00:00Added an answer on June 17, 2026 at 8:09 pm

    Method 1

    will be better, as they are direct and knows for that control they are responding too

    Regarding

    Method 2

    each time the sender(object) is casted to TextBox and then the switch statement decides the Operation on the control.

    so it is obvious that, Method1 will be more effective


    Have a look at these links too : How expensive is Casting, Performance of Typecasting

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

Sidebar

Related Questions

So, let's say I had an app that used the same method to schedule
I have used same command button Click event for both Insert, Update functionalities. I'm
I used same function ( OneWayEncrypt(edit1.Text) ) in Delphi 5 and 2010. Why the
I know the default is ByVal in C#. I used same variable names in
I used the same software used here http://us.gn.bartal.org/ to create a fixed width/height treemap
I used the same command syntax above as in Mysql and would like set
This one boggles my mind. I've used this same script (different targets of course)
I don't understand why I'm getting this error. I used the same code previously
I have some objects which will be used in the same manor. This object
Is there a Python module that can be used in the same way as

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.