views:

77

answers:

1

I have this version:

Microsoft Visual C# 2008 Express Edition

Using this function:

var X = new WebClient();

Var isn't recognized by my IDE. Thanks.

+7  A: 

Are you trying to use it for a class member? var is only valid for local variables within a function.

P Daddy
Aha! That would be it my friend. Any logical reason as to WHY this is made this way? I'm new to using Vars. Is it because it would be system intensive because the compiler can't infer what type of variable is being saved to it?
Sergio Tapia
@Papuccino1: See http://blogs.msdn.com/ericlippert/archive/2009/01/26/why-no-var-on-fields.aspx
Jon Skeet