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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:31:58+00:00 2026-06-10T12:31:58+00:00

I have implemented a strongly typed implementation of INotifyPropertyChanged, except instead of using the

  • 0

I have implemented a strongly typed implementation of INotifyPropertyChanged, except instead of using the interface, I have added a base class to implement.

It works fine, but the bit I am struggling with is why TValue is used in the base method declaration (I did use this section from some code I found online)

NotifyPropertyUpdate<TValue>(…

BUT in the derived class, it doesn’t need to pass TValue at all!

What tells the compiler to resolve this at runtime instead of complaining at build?

Thanks,

Base class:

public class NotifyFuncPropertyChanged<T> : INotifyPropertyChanged
{
    #region Implementation of INotifyPropertyChanged

    public event PropertyChangedEventHandler PropertyChanged;

    protected void NotifyPropertyUpdate<TValue>(Expression<Func<T, TValue>> selector)
    {
        //get memberInfo from object selection
        MemberInfo memberInfoSelection;
        Expression body = selector;
        if (body is LambdaExpression)
        {
            body = ((LambdaExpression)body).Body;
        }
        switch (body.NodeType)
        {
            case ExpressionType.MemberAccess:
                memberInfoSelection =((MemberExpression)body).Member;
                break;
            default:
                throw new InvalidOperationException();
        }

        //send notifyupdate to memberInfo
        if (PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(memberInfoSelection.Name));
        }
    }

    #endregion
}

Usage (derived class)

public class NameTest : NotifyFuncPropertyChanged<NameTest>
{
    public string Name { get; set; }

    public void TestUpdateName()
    {
        this.NotifyPropertyUpdate(x => x.Name);
    }
}
  • 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-10T12:31:59+00:00Added an answer on June 10, 2026 at 12:31 pm

    The C# compiler has a feature called Type inference. You can read about it in all its complexity in the language specification, in section 7.5.2, or there’s a very brief introduction here.

    From the spec:

    When a generic method is called without specifying type arguments, a
    type inference process attempts to infer type arguments for the call. The presence of type inference allows a more convenient syntax
    to be used for calling a generic method, and allows the programmer to
    avoid specifying redundant type information. For example, given the
    method declaration:

    class Chooser
    {
      static Random rand = new Random();
      public static T Choose<T>(T first, T second) {
          return (rand.Next(2) == 0)? first: second;
      }
    }
    

    it is possible to invoke the Choose method without explicitly
    specifying a type argument:

    int i = Chooser.Choose(5, 213);                   // Calls Choose<int>
    string s = Chooser.Choose("foo", "bar");      // Calls Choose<string>
    

    Through type inference, the type arguments int and string are
    determined from the arguments to the method.

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

Sidebar

Related Questions

We're just getting into MVVM in WPF. We have implemented our ViewModels with 'strongly
I have implemented correctly bump's api, and added this code: - (void) configureBump {
I have implemented clean URLs using the following in my .htaccess RewriteEngine on RewriteCond
I have implemented a very basic sign up using email address+name, although I would
I have designed a class with sqlClient.SqlCommand wrappers to implement such functionality as automatic
I have a winforms app that uses a strongly typed custom DataSet for holding
Hi, I have a Strongly typed view in ASP.NET MVC. To keep track on
I've got a bunch of strongly typed DataSet that each have two tables. One
I have a strongly typed viewpage that I created that looks like this: <%@
Say I have a DataGridView (named dataGridView ) that is displaying a Strongly Typed

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.