Click here to Skip to main content
15,903,175 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Unable to include 'VAR' implicitly typed variable in Class Library. Getting "The type or namespace name 'var' could not be found (are you missing a using directive or an assembly reference?)" error. :)

Steps to recreate:
1)Import new Class Library.write the 'VAR' variable inside the class.
2)Namespace declared
using System;
using System.Collections.Generic;
using System.Linq;
using System.Data.Linq;

Please advice friends.:confused:
Posted
Updated 9-Dec-10 10:09am
v3
Comments
Henry Minute 9-Dec-10 16:11pm    
Please edit your question to include the section of code where the error occurs. DO NOT add an answer, use the 'Improve Question' widget at the bottom right of your question.

1 solution

var can only be used inside a method/property. In other words, you can't get there from... ummm... there.
 
Share this answer
 
Comments
Dhanamanikandan 10-Dec-10 13:33pm    
now able to use. thnkx

I have one more question why we can use 'VAR' only inside the method? why we cant use in class as below program. Please refer the program
[namespace DataAccessLayer
{
public class ProjectDetailsDAL
{
int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };

var numsPlusOne =
from n in numbers ]

Please advice...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900