C# struct Constructors As Shown in IntelliSense? (M'soft Rep PLease)

  • Thread starter Thread starter Peter van der Goes
  • Start date Start date
P

Peter van der Goes

When a struct is created in C# and a parameterized constructor defined, the
IntelliSense editor shows only the syntax for the parameterized constructor
in tooltips, but not for the default constructor which appears to still
exist. If this is not designed behavior, is it a bug or am I misusing my
struct?
If it is by design, could you please explain? I realize the behavior of a
struct, as regards constructors, is different from that of classes in that a
class will not retain an automatically defined default constructor if a
parameterized constructor is defined by the programmer. The tooltip for
struct constructor options seems to be following the rules for a class?
I'm a bit confused, and any help getting straight would be much appreciated!
 
Quoting MSDN:

"It is an error to declare a default (parameterless) constructor for a
struct. A default constructor is always provided to initialize the struct
members to their default values."

The gist is that you can't override what the default constructor does. The
framework is boss :)

Cheers,

4Space
 
It SHOULD show the default one the system uses as its AVAILABLE to the
instantiator.

Its an intellisense bug. THey just dont admit it.

If its available to the caller it should be visible to on the intellisense,
if they say otherwise, theyre talkin crrap
 
You must init ALL member fields on a param constructor, but intellisense
does have a bug on not displaying the default constructor for the
instantiator.

You CAN have a line like...

SomeStruct somethingStructure = new SomeStruct();

You dont define the default constructor the system does on structs. But
intelilsense SHOULD show the availability of the default constructor on the
above line but it doesnt. Its saying its not available yet it is. BUG.
 
news.microsoft.com said:
It SHOULD show the default one the system uses as its AVAILABLE to the
instantiator.

Its an intellisense bug. THey just dont admit it.

If its available to the caller it should be visible to on the intellisense,
if they say otherwise, theyre talkin crrap
I'm afraid I have to be a bit blunt here.
I reposted your issue in a different thread to elicit a response from a
Microsoft rep by eliminating the combative rhetoric. Statements like "they
just don't admit it" with no evidence to support such an accusation, are not
going to help get an answer.
 
4Space said:
Quoting MSDN:

"It is an error to declare a default (parameterless) constructor for a
struct. A default constructor is always provided to initialize the struct
members to their default values."

The gist is that you can't override what the default constructor does. The
framework is boss :)

Cheers,

4Space
Yes, I'm aware of that.
The issue is why the tooltips in the intellisense editor don't show the
retained default version in the case of a struct vs. a class. If a
parameterized constructor is declared in a class definition, the
compiler-supplied default constructor is not retained, and the programmer
must write one if it's needed. In a struct, the compiler-supplied default is
retained after declaration of a parameterized constructor, but its prototype
doesn't show up as an option in the tooltip.
Not exactly a showstopper, but the behavior as reported can be replicated.
 
When I get pissass excuses back like "By design" etc thats just a lazy
halfarsed implentation.
 
You are right it's a known bug.

Willy.

news.microsoft.com said:
You must init ALL member fields on a param constructor, but intellisense
does have a bug on not displaying the default constructor for the
instantiator.

You CAN have a line like...

SomeStruct somethingStructure = new SomeStruct();

You dont define the default constructor the system does on structs. But
intelilsense SHOULD show the availability of the default constructor on the
above line but it doesnt. Its saying its not available yet it is. BUG.
 
Every struct in c# has a default constructor available and you cannot
override or hide it. what sense would it make to show it in intellisense?
 
codymanix said:
Every struct in c# has a default constructor available and you cannot
override or hide it. what sense would it make to show it in intellisense?

Intellisense should show you what's available to call. When you've got
as far as new DateTime( then the parameterless constructor should be
one of the options available.

It's not as big a deal as is being made out here, but it's not the
desired behaviour IMO.
 
Obviously you do not understand the purpose of Intellisense.

--

Jack Mayhoff
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Obviously you do not understand the purpose of Intellisense.

intellisense is for help you typing. but in this case intellisense will pop
up when you already typed the whole line just the () are missing

S s = new S(

here at this point, intellisense will pop up. what is the gain? it will help
me writing the closing parenthese!

the second purpose of intellisense is that it informs you about the members
of a class. in the case somebody really doesn't know that a struct always
must have a default ctor maybe.

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu
[noncommercial and no ****ing ads]
 
Its a bug. It should still popup the ToolTip for the default ctor.

--

Jack Mayhoff
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

cody said:
Obviously you do not understand the purpose of Intellisense.

intellisense is for help you typing. but in this case intellisense will pop
up when you already typed the whole line just the () are missing

S s = new S(

here at this point, intellisense will pop up. what is the gain? it will help
me writing the closing parenthese!

the second purpose of intellisense is that it informs you about the members
of a class. in the case somebody really doesn't know that a struct always
must have a default ctor maybe.

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu
[noncommercial and no ****ing ads]
 
Back
Top