Click here to Skip to main content
11,920,211 members (49,282 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# .NET DLL
hi all
Actually i have one dll name demodll.
which contains this code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace demoDll
    public class Class1
        public virtual int ADDNumbers(int a, int b,int c)
            return 0;

now i am adding this dll into another dot net application as a reference.
i want to override this ADDNumbers function in my dot net application.
i want to write implementation for this function.
how can i do it??
Anyone have any sample code or any tutorial which i can go through..
please help..
god bless you all
thank you..Smile | :)
Posted 29-Aug-12 2:33am
Wes Aday 29-Aug-12 7:36am
What do you mean that you want to override this method? If you want to call a different method than this one then call the other method. There is no "overriding" here.
MAU787 29-Aug-12 7:54am
i just want to know if there any way we can implement function which is declared in dll?
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Reference that DLL in another project.

Use the namespace (using demoDll).

Extend the class (public class ImplementingClass : Class1) and override the method as normal
public class ImplementingClass : Class1 {
 public override int ADDNumbers(int a, int b, int c){ ... }

It looks like you're trying to do a 'pure virtual function' (C++ terminology) in which case you should make the method abstract, not virtual, in the DLL, and likely make Class1 an interface instead.
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

Yesterday, there was a correct answer. Now it's gone, so I'm going to reproduce it here:

Change your in-dll-code to
public abstract class Class1
    public abstract int ADDNumbers(int a, int b,int c);
This doesn't provide any implementation for AddNumbers() at all, but is enforcing that you override it in every derived class.

Your actual application includes the dll. Do the subclassing there including the implementation of AddNumbers().

If that's all you want from Class1, you can also turn it into an interface instead of a class. That would allow the classes in your application to derive from something else and implement this interface at the same time.

Oh, and the derived class would be something like
public class Class2 : Class1
    // The compiler will not allow any Class1-derived
    //   class unless it implements AddNumbers()
    public override int ADDNumbers(int a, int b, int c)
        return( a + b + c);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 455
1 phil.o 170
2 CPallini 150
4 F-ES Sitecore 130
0 OriginalGriff 6,778
1 KrunalRohit 4,495
2 Sergey Alexandrovich Kryukov 3,153
3 George Jonsson 2,810
4 Suvendu Shekhar Giri 2,181

Advertise | Privacy | Mobile
Web02 | 2.8.151120.1 | Last Updated 30 Aug 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100