Auto-complete in Visual Studio

D

David P. Donahue

I've always used VB in Visual Studio and have just started porting some
of my stuff to C#, but I'm noticing something odd in Visual Studio
(2003, if that's important). When writing VB code, the IDE would always
show me all the classes/properties/etc. available to me at any given
time in a dropdownlist as I typed. However, that doesn't seem to be
happening with C#. It seems to be a case of the IDE not knowing the
reference paths or something because I also need to give entire paths
(System.Web.UI.WebControls.ListItemType instead of just ListItemType) to
get it to compile. Is there something I need to do to point the IDE at
the right paths? (I'm not sure if my terminology in this question was
correct... but hopefully you get the idea.)


Regards,
David P. Donahue
(e-mail address removed)
 
D

David P. Donahue

PS: I just checked the project properties (it's an ASP .NET Web
Application project, by the way) and saw that the "References Path"
section was empty, whereas with VB is would have things like "System,
System.Web, etc." But when I go to add one it seems like it's looking
for a file on the file system, not a namespace in the class hierarchy?
These namespaces are shown in the References "folder" in my Solution
Explorer, however.


Regards,
David P. Donahue
(e-mail address removed)
 
J

Jon Skeet [C# MVP]

David P. Donahue said:
PS: I just checked the project properties (it's an ASP .NET Web
Application project, by the way) and saw that the "References Path"
section was empty, whereas with VB is would have things like "System,
System.Web, etc." But when I go to add one it seems like it's looking
for a file on the file system, not a namespace in the class hierarchy?
These namespaces are shown in the References "folder" in my Solution
Explorer, however.

The references path in VC# is for file system directories to look for
assemblies in. It enables the project to keep a relative filename to
the assembly rather than an absolute one. I guess it's different in
VB.NET.
 
J

Jon Skeet [C# MVP]

David P. Donahue said:
I've always used VB in Visual Studio and have just started porting some
of my stuff to C#, but I'm noticing something odd in Visual Studio
(2003, if that's important). When writing VB code, the IDE would always
show me all the classes/properties/etc. available to me at any given
time in a dropdownlist as I typed. However, that doesn't seem to be
happening with C#. It seems to be a case of the IDE not knowing the
reference paths or something because I also need to give entire paths
(System.Web.UI.WebControls.ListItemType instead of just ListItemType) to
get it to compile. Is there something I need to do to point the IDE at
the right paths? (I'm not sure if my terminology in this question was
correct... but hopefully you get the idea.)

That suggests you need the appropriate using statements at the top of
your code, eg

using System;
using System.Web.UI.WebControls;
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,


David P. Donahue said:
I've always used VB in Visual Studio and have just started porting some
of my stuff to C#, but I'm noticing something odd in Visual Studio
(2003, if that's important). When writing VB code, the IDE would always
show me all the classes/properties/etc. available to me at any given
time in a dropdownlist as I typed.

It works the same in C#
However, that doesn't seem to be
happening with C#. It seems to be a case of the IDE not knowing the
reference paths or something because I also need to give entire paths
(System.Web.UI.WebControls.ListItemType instead of just ListItemType) to
get it to compile. Is there something I need to do to point the IDE at
the right paths? (I'm not sure if my terminology in this question was
correct... but hopefully you get the idea.)


Did you create this page with the IDE ? selecting Add a new WebForm ? if so
you would have all you need. It seems that you did not follow this approach
as you have no "using" statement . So it's probably that you also miss some
other important code in the page.

Pd:
If what you did was rename a VB code file to CS and start converting all
the lines , it's not the best approach, you better create a new webform frmo
the IDE and start adding the code from VB one method at a time


Cheers,
 
D

David P. Donahue

For whatever reason the proper "using" statements weren't in place. I
am using the IDE. But, it's working now. One last thing on this thread
then would be the issue of case sensitivity in C#. When I'm typing out
the name of a variable and press "." at the end, I only see the
available properties/etc. if the variable name is properly capitalized
to match its original declaration. Is this just part of the language
itself? Is there any way to get the IDE to do the capitalization for me
after the fact, like with VB?


Regards,
David P. Donahue
(e-mail address removed)
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Get used to it, it will happen always, there is no way for the IDE to
capitalize for you, as the upper/lower are differents it cannot do something
like this. In c# you can do (but is not recommended ):
string str;
public string Str{ get {return str;} }

that is a very good example of why the IDE cannot do the capitalization for
you, cause the same identifier may have different meaning regarding the
capitalization.


if you mantain a consistent naming convention you will find it very easy.

Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top