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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:09:13+00:00 2026-05-17T23:09:13+00:00

i need to define a class partially in seperate assemblies. actually i need to

  • 0

i need to define a class partially in seperate assemblies. actually i need to redefine a class partially, that is already defined in an assembly written in C++ Cli, but this is maybe a different question.
for the case, all codes written in c#, i have a baseclass definition in basenamespace assembly

using System;

namespace BaseNameSpace
{
  public class BaseClass
  {
    public int Num;
    public double dNum;
    public BaseClass(int s, double d)
    {
      Num = s;
      dNum = d;
    }

    public virtual void Wrt()
    {
      Console.WriteLine("{0},{1}", Num, dNum);
    }
  }
}

i add another assembly project called derivedclassSpace and declare a derivedclass derived from baseclass. i also add a partial class definition to this project.

using System;
using BaseNameSpace;

namespace BaseNameSpace
{
  public partial class BaseClass
  {
    public void Mult()
    {
      Num *= 2;
    }
  }
}

namespace DerivedNameSpace
{
  public class DerivedClass : BaseClass
  {
    public DerivedClass(int s)
      : base(s, 0)
    {

    }

    public override void Wrt()
    {

      Mult(); // mult line
      base.Wrt();
    }
  }
}

when i build the solution i get

‘DerivedNameSpace.DerivedClass.Wrt()’:
no suitable method found to override

if i remove the partial class lines and mult line, everything is normal.
am i using the concept of partial keyword? how can i get rid of the error?

  • 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-17T23:09:14+00:00Added an answer on May 17, 2026 at 11:09 pm

    You cannot define a partial class across assemblies. Partial classes (and partial methods) are just compiler features that allow you to split up the definition across files. Once the assembly is compiled, there is a single class. Your only real option is to inherit from the base class, add your function, then have further derived classes inherit from this new class.

    If all you’re trying to do is add a method to an existing class, however, you might consider an extension method. While this doesn’t actually add it to the class per se, it does allow you to write your code as if it had.

    namespace BaseNameSpace
    {
      public static class BaseClassExtensions
      {
        public static void Mult(this BaseClass instance)
        {
          instance.Num *= 2;
        }
      }
    }
    
    namespace DerivedNameSpace
    {
      public class DerivedClass : BaseClass
      {
        public DerivedClass(int s)
          : base(s, 0)
        {
    
        }
    
        public override void Wrt()
        {
    
          Mult(); // mult line
          base.Wrt();
        }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class that defines a CallRate type. I need to add the
I need to define a calculated member in MDX (this is SAS OLAP, but
I often want to define new 'Exception' classes, but need to have an appropriate
I need to define new UI Elements as well as data binding in code
I'm writing a config file and I need to define if the process expects
I'm fiddling with calling DLLs from C#, and came across the need to define
I need your help to define a special case in XML schema: A sequence
I believe I need a DTD to define the schema and an XSLT if
I need to enumerate all the user defined types created in a SQL Server
I need to replace one of the pre-defined window classes all across Windows. For

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.