Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The type or namespace name 'var' could not be found in WCF Service Application

Tags:

When I am trying to use "var" in the WCF Service application it is giving error "The type or namespace name 'var' could not be found (are you missing a using directive or an assembly reference?)"

like image 483
Milan Raval Avatar asked Mar 17 '11 09:03

Milan Raval


1 Answers

You get this error if you try to use var in a class member, e.g.:

public class Foo {     var a = 4; } 

var can only be used inside a method, not in classes, fields or method signatures.

See also: Why no var on fields?

like image 197
Kobi Avatar answered Oct 05 '22 05:10

Kobi