| | |
how to run the linq program in ordinary console application
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2008
Posts: 56
Reputation:
Solved Threads: 0
hi,
i am doing the project in .net. i m using linq in my project
i using vs2005 and installed the linq.
i am able to run the linq only in LinqconsoleApplication. but i need to run in normal console application.
ie i like to create one class file and do some linq operations. but in normal class or console application, i m not able to r u the linq operations
i m using the following headers....
using System;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.DLinq;
using System.Data.Linq;
using System.Query;
using System.Reflection;
using System.Expressions;
using System.Query.Script;
class pr
{
var x =new int[] {1,2,3,4,5,6,7,8};
var ev=from a in x
where (ev %2)==0
select a;
foreach(var i in ev)
console.writeline(i);
}
after compile this code
i got the type or namespace var can't find out..
if u know the solution for the above one. please share ur ideas....
i am doing the project in .net. i m using linq in my project
i using vs2005 and installed the linq.
i am able to run the linq only in LinqconsoleApplication. but i need to run in normal console application.
ie i like to create one class file and do some linq operations. but in normal class or console application, i m not able to r u the linq operations
i m using the following headers....
using System;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.DLinq;
using System.Data.Linq;
using System.Query;
using System.Reflection;
using System.Expressions;
using System.Query.Script;
class pr
{
var x =new int[] {1,2,3,4,5,6,7,8};
var ev=from a in x
where (ev %2)==0
select a;
foreach(var i in ev)
console.writeline(i);
}
after compile this code
i got the type or namespace var can't find out..
if u know the solution for the above one. please share ur ideas....
•
•
Join Date: Aug 2008
Posts: 1,735
Reputation:
Solved Threads: 186
1. Please use whole words.
2. Please post the proper error text
3. What line is the err on
4. A console app is a console app, the only difference will be that it has linq already in the references and uses clause you should be able to just run it from a command line
2. Please post the proper error text
3. What line is the err on
4. A console app is a console app, the only difference will be that it has linq already in the references and uses clause you should be able to just run it from a command line
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
•
•
•
•
i using vs2005 and installed the linq.••••var is a C# 3.0 feature; it can't possibly work with a C# 2 compiler.
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Yes because he doesn't write this code within method!!
but I was replying in language syntax perspective...
but I was replying in language syntax perspective... BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
•
•
Join Date: Oct 2008
Posts: 56
Reputation:
Solved Threads: 0
using System;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.DLinq;
using System.Data.Linq;
using System.Query;
using System.Reflection;
using System.Expressions;
using System.Query.Script;
namespace consoleapplication1
{
class Program
{
static void main()
{
var num =new int[] {1,2,3,4,5,6,7,8,9};
var evennumbers= from n in num
where (n %2) ==0
select n;
foreach(var x in evennumbers)
console.writeline(x);
}
}
}
I wrote this code in ordinary console application in VS2005.
i compiled this code, after compilation i got the following errors
"Error 1 The type or namespace name 'var' could not be found (are you missing a using directive or an assembly reference?) "
// Error 2 is above one
Error 3 foreach statement cannot operate on variables of type 'var' because 'var' does not contain a public definition for 'GetEnumerator'
//Error 4= Error 1
Error 5 The best overloaded method match for 'System.Console.WriteLine(bool)' has some invalid arguments
These are arise during compile time.
but one think the same code is executed in Previewconsole application in VS2005.
but i need it to run normal ConsoleApplication in VS2005.
i my organization have not VS2008. so i must work in VS2005.
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.DLinq;
using System.Data.Linq;
using System.Query;
using System.Reflection;
using System.Expressions;
using System.Query.Script;
namespace consoleapplication1
{
class Program
{
static void main()
{
var num =new int[] {1,2,3,4,5,6,7,8,9};
var evennumbers= from n in num
where (n %2) ==0
select n;
foreach(var x in evennumbers)
console.writeline(x);
}
}
}
I wrote this code in ordinary console application in VS2005.
i compiled this code, after compilation i got the following errors
"Error 1 The type or namespace name 'var' could not be found (are you missing a using directive or an assembly reference?) "
// Error 2 is above one
Error 3 foreach statement cannot operate on variables of type 'var' because 'var' does not contain a public definition for 'GetEnumerator'
//Error 4= Error 1
Error 5 The best overloaded method match for 'System.Console.WriteLine(bool)' has some invalid arguments
These are arise during compile time.
but one think the same code is executed in Previewconsole application in VS2005.
but i need it to run normal ConsoleApplication in VS2005.
i my organization have not VS2008. so i must work in VS2005.
Create project from LINQ Console Application not Console Application
You'll find some project with prefix "LINQ" added to project types in VS2005 after installing LINQ SDK.
If you can send us snapshot of your VS installed project templates please do.
You'll find some project with prefix "LINQ" added to project types in VS2005 after installing LINQ SDK.
If you can send us snapshot of your VS installed project templates please do.
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
![]() |
Other Threads in the C# Forum
- Previous Thread: Capture your screen in a bitmap.
- Next Thread: The 2000 first primes
Views: 1007 | Replies: 8
| Thread Tools | Search this Thread |
Tag cloud for C#
.net access ado.net algorithm array barchart bitmap box broadcast button buttons c# chat check checkbox class client color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development drawing encryption enum event excel file files form format ftp function gdi+ httpwebrequest image index input install java label list listbox listener login mandelbrot math mouseclick mysql networking object oracle path photoshop picturebox pixelinversion post prime programming radians regex remote remoting resource richtextbox save saving serialization server sleep socket sql statistics stream string table tcp text textbox thread time timer treeview update usercontrol validation view webbrowser windows winforms wpf xml






