Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 One C# issue (I think)

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
pwaugh Posted - Mar 04 2008 : 4:08:39 PM
Ok, this could be a defective programmer, but here is what I notice:

If I am programming in C# and have this class:


namespace House
{
	class Outside : Location
	{
		public Outside(bool hot, string name)
			: base(name)
		{
			this.hot = hot;   // Problem to type
		}

		public bool Hot { get; }
	}
}


VAX makes it difficult for me because when I try to type "this.hot" and then press [space] it converts my "hot" which is a hidden backing field of the Hot property to "Hot".

Looks like you are going to need language specific features after all. =)

Is there anything that can be done about this behavior? I though I was screwing up code till I watched while I typed and saw VAX changing it for me.

Patrick
5   L A T E S T    R E P L I E S    (Newest First)
pwaugh Posted - Mar 09 2008 : 06:17:09 AM
Hey, thanks for the info. As you can tell, I'm just learning C#, and I thought it might have something to do with me doing something wrong as you have pointed out. =)
StarWing Posted - Mar 08 2008 : 11:34:52 PM
Yes, it always occurs when i use C++....
mwb1100 Posted - Mar 06 2008 : 8:10:35 PM
When using auto-implemented properties, the 'hidden' private field that backs the property is not directly accessible, even inside the class. The backing field does not have the same name as the property changed to lowercase - the name is something like '<propertyName>k__BackingField'. So in your example code the backing field for the Hot property is named '<Hot>k__BackingField'. Note that it's not a valid C# identifier.

See http://community.bartdesmet.net/blogs/bart/archive/2007/03/03/c-3-0-automatic-properties-explained.aspx for details, but realize that it looks like the naming details have changed in the final release.

So the "this.hot = hot" expression won't compile even if you could type it easily.

From the MSDN documentation: "Auto-implemented properties must declare both a get and a set accessor. To create a readonly auto-implemented property, give it a private set accessor".

So, you'd need to change your example to look something like:


class Outside
{
    public Outside(bool hot, string name)
    {
        this.Hot = hot;
    }

    public bool Hot { get; private set;}
}

pwaugh Posted - Mar 06 2008 : 6:26:19 PM
It is a .NET 3.5 feature only I think (won't work in VS 2005).

Patrick
feline Posted - Mar 06 2008 : 3:56:06 PM
Does this compile? It does not compile for me, but I do not know what namespace "Location" is from, so I do not have the correct using statement.

I did the following test, using your code with using VS2005 and VA 1626
I disabled VA via the VAssistX IDE menu.
I typed

this.|

underneath your line, and press CTRL-SPACE to trigger a listbox. I now continued typing, including the space:

this.hot |

and when I press the space the IDE accepts the current suggestion "Hot" from the listbox and replaces "hot" with "Hot". The same thing may be happening to you.

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000