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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:47:24+00:00 2026-05-20T20:47:24+00:00

I would look this up on Google/MSDN, but I have no idea what it’s

  • 0

I would look this up on Google/MSDN, but I have no idea what it’s called so I’m asking here.

In Java, I seem to remember you can do this really cool thing like:

Class MyClass
{
  int number;

  MyClass() { }

  void setNumber(int number)
  {
    this.number = number;
  }
}

and then do something like:

MyClass myClass = new MyClass()
  {
    override void setNumber(int Number)
    {
      this.number = 2 * number;
    }
  };

…or something. Forgive any mistakes I made above – I haven’t actually touched Java in about 6 years.

The point is, I remember you could pseudo-extend a class inline.

Right now, I need to extend a C# WinForms control, but I only need to use it once, and the modifications are very minor. All I need to do is to override the CreateParams property and OnPaint() handler.

My solution is already getting huge with classes all over the place, it seems like a shame to include yet another class which is basically identical to a standard .Net control, just with very slightly different behaviour.

Is it possible to do this inline-extension in C# like you could in Java? If so, how? (and what is it called so I can look it up on MSDN?)

  • 1 1 Answer
  • 2 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-20T20:47:24+00:00Added an answer on May 20, 2026 at 8:47 pm

    This (explicit nominative anonymous types) is not possible in C#3/4.

    The types must be created explicitly and then constructed. Tasks are sometimes “inverted” in C# with the use of Events and Delegates (class invokes Event which supplies implementation such as “NeedDataSource”) — arguably because of this, although it just makes sense in many cases.

    If is possible to create explicit non-nominative types: var x = new { P = 1, }; but only in a local scope. Implicit methods include delegates/lambdas/anonymous functions and do not apply here.

    Happy coding.

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

Sidebar

Related Questions

In Java, a 'static method' would look like this: class MyUtils { . .
I think this would increase the quality of life when devving, but google came
i want to realize a construct in MS SQL that would look like this
I would really appreciate if you would take a look at this piece of
Please take a look at this screenshot first: I would like to move the
i have a table (tbl_world) which look like this id | first_name | last_name
I am trying to have a URL that would look like: mysite.com/@username Which would
I have been google-ing around for the answer to this for that last hour
I'm trying to parse the following URI : http://translate.google.com/#zh-CN|en|你 but got this error message
I'm building a multiuser realtime application with Google App Engine (Python) that would look

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.