Interfector
Interfector

Reputation: 1898

Cannot create simple class

I am trying to create a very simple CUser class in my project, but apparently I am doing something wrong. Here is the code:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MySql.Data.MySqlClient;

namespace admin.NET.lib {
    public class CUser {
        protected MySqlConnection conn;

        public void CUser() {
        }
    }
}

This simple piece of code gives me:

'CUser': member names cannot be the same as their enclosing type

Can anyone give me a hint to where I must modify this to work. I saw that this problem poped before but I could not adapt the solutions to my code.

Thanks

Upvotes: 1

Views: 127

Answers (3)

Stephane Halimi
Stephane Halimi

Reputation: 508

public CUser() { } Would be better !

Your contructor returns a reference to the object it create, this is his job :-).

Upvotes: 0

ASergan
ASergan

Reputation: 171

Bad constructor. Read .net base information.

Upvotes: 0

John Saunders
John Saunders

Reputation: 161831

Remove the void. Constructors have no return type.

Upvotes: 10

Related Questions