Are these good features to use?

  • Thread starter Thread starter David Thielen
  • Start date Start date
D

David Thielen

Hi;

I've got 2 questions about features in the new C#.

The first is where I can do "var x = new MyObject()" instead of
"MyObject x = new MyObject()". This strikes me as a step back to Basic
as it's good to explicitly declare what I'm creating. Am I just being
too resistent to change? Or do others find this not a feature to use.

My second is the auto-properties where a private variable is just
marked as a property. O see this as being more useful, but again I
think having it written in code makes it clearer. What do people who
are using this think of it?

thanks - dave

david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
Hi Dave,

As for "var" like anonymous variable in C# or VB.NET(.net 3.5), they're
different than the original VB6 or VB.NET's var, they're not late binding
code. They're still strong-type code, but just provide a mechanism to let
the compiler help choose the appropriate type which is necessary to support
those new cool features such as LINQ.

IMO, as long as your code doesn't use a feature that does require you to
declare variables as var, it is always good practice to explicitly declare
the type. Which adds code's readability.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
 
Thank you both. Ok, I'm sticking with explicit declarations of
variable types but I'll switch over to the auto properties.

thanks - dave


Hi Dave,

As for "var" like anonymous variable in C# or VB.NET(.net 3.5), they're
different than the original VB6 or VB.NET's var, they're not late binding
code. They're still strong-type code, but just provide a mechanism to let
the compiler help choose the appropriate type which is necessary to support
those new cool features such as LINQ.

IMO, as long as your code doesn't use a feature that does require you to
declare variables as var, it is always good practice to explicitly declare
the type. Which adds code's readability.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 

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

Back
Top