473,490 Members | 2,458 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

'member names cannot be the same as their enclosing type

Nik

I keep getting the following error 'member names cannot be
the same as their enclosing type' with the code below.

public class HelpText
{
private string _textToDisplay;
private string _cssClass;

public string TextToDisplay {
get {return _textToDisplay;}
set {_textToDisplay = value;}
}

public string CssClass {
get {return _cssClass;}
set {_cssClass = value;}
}

public string HelpText()
{
WebAuthorContext authorContext =
WebAuthorContext.Current();

//Check if in edit mode
if (authorContext.Mode ==
WebAuthorContextMode.AuthoringNew || authorContext.Mode ==
WebAuthorContextMode.AuthoringReedit) {
HelpText = "<span
class=\"" + CssClass + "\">" + TextToDisplay + "</span>";
}
} }

any ideas?
Nov 15 '05 #1
5 32717
You declare a constructor for the class HelpText that returns a value - a string. Constructors do not return any type. They just construct the object of the type. You should move the code that returns your constructed string to another method. Although, you can still build the string in the constructor and store it in a member variable.

--
Cezary Nolewajka
mailto:c.*********************@no-sp-am-eh-mail.com
remove all "no-sp-am-eh"s to reply
"Nik" <an*******@discussions.microsoft.com> wrote in message news:90****************************@phx.gbl...

I keep getting the following error 'member names cannot be
the same as their enclosing type' with the code below.

public class HelpText
{
private string _textToDisplay;
private string _cssClass;

public string TextToDisplay {
get {return _textToDisplay;}
set {_textToDisplay = value;}
}

public string CssClass {
get {return _cssClass;}
set {_cssClass = value;}
}

public string HelpText()
{
WebAuthorContext authorContext =
WebAuthorContext.Current();

//Check if in edit mode
if (authorContext.Mode ==
WebAuthorContextMode.AuthoringNew || authorContext.Mode ==
WebAuthorContextMode.AuthoringReedit) {
HelpText = "<span
class=\"" + CssClass + "\">" + TextToDisplay + "</span>";
}
} }

any ideas?

Nov 15 '05 #2
"Nik" <an*******@discussions.microsoft.com> wrote:

<snip>
HelpText = "<span
class=\"" + CssClass + "\">" + TextToDisplay + "</span>";


Why are you assigning *HelpText* a string value? HelpText is the name
of your class!

<snip>
Nov 15 '05 #3

"C# Learner" <cs****@learner.here> wrote in message
news:2c********************************@4ax.com...
"Nik" <an*******@discussions.microsoft.com> wrote:

<snip>
HelpText = "<span
class=\"" + CssClass + "\">" + TextToDisplay + "</span>";
Why are you assigning *HelpText* a string value? HelpText is the name
of your class!


In VB, it's how you return a value.


<snip>

Nov 15 '05 #4
I can't understand what you're try to do from your code.
What are you trying to do?

- pete

"Nik" <an*******@discussions.microsoft.com> wrote in message
news:90****************************@phx.gbl...

I keep getting the following error 'member names cannot be
the same as their enclosing type' with the code below.

public class HelpText
{
private string _textToDisplay;
private string _cssClass;

public string TextToDisplay {
get {return _textToDisplay;}
set {_textToDisplay = value;}
}

public string CssClass {
get {return _cssClass;}
set {_cssClass = value;}
}

public string HelpText()
{
WebAuthorContext authorContext =
WebAuthorContext.Current();

//Check if in edit mode
if (authorContext.Mode ==
WebAuthorContextMode.AuthoringNew || authorContext.Mode ==
WebAuthorContextMode.AuthoringReedit) {
HelpText = "<span
class=\"" + CssClass + "\">" + TextToDisplay + "</span>";
}
} }

any ideas?

Nov 15 '05 #5
Nik wrote:
I keep getting the following error 'member names cannot be
the same as their enclosing type' with the code below.


The class HelpText may not contain a method named HelpText. Only
constructors may have the same name as their enclosing type.

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
Nov 15 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
2207
by: BRIAN VICKERY | last post by:
I've heard that some compilers reserve the '_' starting a symbol for system variables/symbols. I can not find this documented anywhere (so far). I've used an '_' at the end of member variables...
5
3111
by: Walter Tross | last post by:
Somebody with a very regulatory mind in this newsgroup has written that it's better not to use a leading underscore for class member names, because names with a leading underscore are used...
1
24228
by: | last post by:
in sub class i can't define a constructor it give me error when i want it to... "category member names cannot be the same as their enclosing type" namespace Database { public class Structure...
6
14533
by: Tim Cartwright | last post by:
I have a page that has the login control on it, nothing else. This page inherits from a master page, neither page has any code in it. This page works perfectly when running on the WebDev debug web...
4
1313
by: Turbot | last post by:
Hello, I have an ENUM that looks like this: Public Enum Locations As Byte Top_Left Top_Middle Top_Right Middle_Left Middle_Middle
2
8600
by: Sharon | last post by:
Hi all. I have a console app which is a remoting server. When trying to access the server using console app client, it works fine. But when i try the same client code from aspx page on iis i get...
1
4478
by: Veerle | last post by:
Hi, I generate class from xsd files using XSDObjectGen. But the generated code doesn't compile because there are properties with the same name as the class name, which is not allowed in C# :...
1
1574
by: asmx126453 | last post by:
hey guys next question :p its about the member names that the cant be the same the precies error is this 'VerzamelbladOverzicht': member names cannot be the same as their enclosing type its...
1
2867
by: Ravikant Varma | last post by:
public partial class frmStoreMaster { private void FillData(string StoreID) { DAStoreMaster objStoreMst = new DAStoreMaster(); ...
0
6967
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7142
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7181
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6847
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7352
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5445
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4875
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
1383
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
272
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.