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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:41:32+00:00 2026-05-24T19:41:32+00:00

I have an extension method I’m trying to make generic, for message passing. public

  • 0

I have an extension method I’m trying to make generic, for message passing.

    public static ActionResult RedirectCompanyMessage<T>(this Controller controller, T mObject, Company company)
    {
        var msg = mObject.ToString()
        ...
    }

the mObject.ToString() is returning junk like System.Data.Entity.DynamicProxies.SerialCode_960A5FEF6FE5426EE5F55B8627454C71E7D088921143DE49B208E7FED043ADA5

But, the base type (the proxy type?) has an overridden ToString().

public partial class SerialCode
{
    //Prints the serial code with dashes every 5 chars
    public new String ToString()
    {
        return Utility.Utility.FormatSerial(this.Serial);
    }
}

So, what’s the deal? During debugging, if I hover over “T”, visual studio shows T mObject as the correct Models.SerialCode, but if I run mObject.GetType() in the immediate window I see FullName = "System.Data.Entity.DynamicProxies.SerialCode_960A5F...

I just want to be able to reliably run the overridden ToStrings() in all my partial classes.

  • 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-24T19:41:33+00:00Added an answer on May 24, 2026 at 7:41 pm

    The problem is that you didn’t “override” .ToString(); you reintroduced it with new. If you want to override, use override, not new.

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

Sidebar

Related Questions

I have following extension method written: static public IQueryable<OutboundPattern> ByClientID(this IQueryable<OutboundPattern> qry, int clientID)
I have an extension method with the following signature: public static Expression<Func<T, bool>> And<T>(this
I have an Extension Method: public static string ToDelimenatedString(this object[] array, string delaminator) {...}
Let's say I have an extension method public static T TakeRandom<T>(this IEnumerable<T> e) {
I have extension method public static T DeepClone<T>(this T source) where T : ISerializable
I have an extension method defined like so: public static TSource MaxBy<TSource, TResult>(this IEnumerable<TSource>
I have extension method: public static IQueryable<TResult> WithFieldLike<TResult>( this IQueryable<TResult> query, Func<TResult, string> field,
I currently have an extension method on System.Windows.Forms.Control like this: public static void ExampleMethod(this
I have an extension method declared in this way: public static IEnumerable<TEntity> AsEnumerable<TEntity>(this IDBQueryable<TEntity>
I have extension method that does something like this public static void DoStuff(this ObjectContext

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.