Welcome to Dream.In.Code
Getting C# Help is Easy!

Join 136,170 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 1,903 people online right now. Registration is fast and FREE... Join Now!




Problems with Constructors {Resolved = true;}

 
Reply to this topicStart new topic

Problems with Constructors {Resolved = true;}

PsychoCoder
12 Dec, 2007 - 11:58 PM
Post #1

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 8,983



Thanked: 125 times
Dream Kudos: 8625
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
I'm creating a C# class file for some freelance work I am doing. I was writing a constructor, which most class files need:

CODE

public InviteSender()
{

}


But InviteSender is underlined with the error

QUOTE

Class, struct, or interface method must have a return type


Now I know they have me on a ton of pain pills and such, but a constructor is a constructor and the one I posted above appears just find to me, can anyone find any mistakes in it?
User is offlineProfile CardPM
+Quote Post

baavgai
RE: Problems With Constructors {Resolved = True;}
13 Dec, 2007 - 03:54 AM
Post #2

Dreaming Coder
Group Icon

Joined: 16 Oct, 2007
Posts: 2,019



Thanked: 105 times
Dream Kudos: 475
Expert In: C, C++, Java, C#, ASP.NET, PHP, Perl, Python, Oracle, SQL Server, MySql, HTML, JavaScript, Lua

My Contributions
The only reason I can think of that you would get this is if it didn't see it inside the class, e.g
CODE

class InviteSender {
} // oops
public InviteSender() { }


User is offlineProfile CardPM
+Quote Post

antonio71
RE: Problems With Constructors {Resolved = True;}
15 Dec, 2007 - 07:01 PM
Post #3

New D.I.C Head
*

Joined: 15 Dec, 2007
Posts: 1


My Contributions
That's right. We all know that constructors must be WITHIN the class of the same name.
User is offlineProfile CardPM
+Quote Post

orcasquall
RE: Problems With Constructors {Resolved = True;}
17 Dec, 2007 - 05:29 AM
Post #4

D.I.C Head
Group Icon

Joined: 14 Sep, 2007
Posts: 158



Thanked: 3 times
Dream Kudos: 50
My Contributions
I might have found the cause. This will give the same error:
CODE

class Class2
{
    public Class1()
    {
    }
}

The squiggly error underline is under "Class1".

My guess is the constructor is named after the wrong class.
User is offlineProfile CardPM
+Quote Post

abbie
RE: Problems With Constructors {Resolved = True;}
4 Jan, 2008 - 11:17 AM
Post #5

New D.I.C Head
*

Joined: 4 Jan, 2008
Posts: 1

Does anyone know how to do methods in c# ? tnx smile.gif
User is offlineProfile CardPM
+Quote Post

Amadeus
RE: Problems With Constructors {Resolved = True;}
4 Jan, 2008 - 12:16 PM
Post #6

g++ -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 12,226



Thanked: 37 times
Dream Kudos: 25
My Contributions
http://www.c-sharpcorner.com/UploadFile/my...MethodsP_1.aspx

http://www.codersource.net/csharp_methods_properties.html

http://www.youcanlearnseries.com/Programmi...ingMethods.aspx

http://www.aspfree.com/c/a/C-Sharp/C-sharp-Methods-part-1/
http://www.google.ca/search?q=c%23+methods...lient=firefox-a

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 12:31AM

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month