Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The namespace bla already contains a definition for (my partial) class

Tags:

c#

class

partial

I've created a program with some very big .cs files. So i tried to split one of them up by using partial classes. So i created a second file with same class name inside and same namespace. I cut some functions from one file and pasted it in the second one. But when i want to run the program it says that the class already exists. But its a partial class it has to have the same name :S

At the first file (ChartWidget.cs) it starts with:

namespace UGS.Sidebar.ChartWidget
{
    public partial class ChartWidget : UserControl
    {
        #region declarations
        private int id = -1;

.....

At the second file (Debugging.cs) it starts with:

namespace UGS.Sidebar.ChartWidget
{
    public partial class ChartWidget : UserControl
    {

        #region debugvars
        Random _r = new Random();
        #endregion
        .....

those files are from an Usercontrol (as you can see) but i dont think that this is the problem?

Hope you guys can tell me why it doesnt work :( And sorry for my bad english i really suck ... :)

like image 750
Maaaario Avatar asked Oct 22 '25 16:10

Maaaario


2 Answers

Check you haven't appended the class name on to the end of a namespace. e.g. if you put your new class into a folder of the same name, it will automatically get suffixed on the namespace name

like image 115
Richard Avatar answered Oct 25 '25 05:10

Richard


No need to inherit from UserControl in second class

like image 33
ZafarYousafi Avatar answered Oct 25 '25 04:10

ZafarYousafi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!