Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialkevin hudson
Courses Plus Student 11,987 PointsHow to do this in repl.it please? Or maybe Visual Studio?
I'm not going to use csharp console for this course. I've been using repl.it to follow along and I need help understanding how to make the query work in repl.it
My code :
Birds.cs
//Objec initialization
public class Bird
{
public string Name{get; set;}
public string Color{get; set;}
public int Sightings{get; set;}
}
Main.cs
using System;
using System.Linq;
using System.Collections.Generic;
class MainClass {
public static void Main (string[] args) {
List<Bird> birds = new List<Bird>
{
new Bird
{
Name = "Cardinal",
Color = "Red",
Sightings = 3
},
new Bird
{
Name = "Dove",
Color = "White",
Sightings = 2
}
};
var canary = new Bird
{
Name = "Canary",
Color = "yellow",
Sightings = 0
};
birds.Add(canary);
foreach(Bird bird in birds){
Console.WriteLine(bird.Name + " " + bird.Color + " " + bird.Sightings);
}
query = from b in birds where b.Color == "Red" select b;
Console.WriteLine(query);
}
}
I'm having an issue with trying to display the LINQ query after the C# foreach loop data
query = from b in birds where b.Color == "Red" select b;
Console.WriteLine(query);
repl.it link : https://repl.it/@agent1red/LINQTraining
Someone else's repl example of LINQ but not a list: https://repl.it/@Ecliptor/C-Linq-Example
I just can't follow along with the console. Does anyone know if I can use Visual Studio? Which project should I select? Do I need to install a LINQ package in VS?
1 Answer
Steven Parker
231,248 PointsTwo things to keep in mind about using the workspaces:
- It's easier to follow along using the same tools as the instructor. You need to be very familiar with any external tool to know when (and how) to alter the steps the instructor is using.
- With a workspace, it's easy to create a "snapshot" and share a link to it so other students can replicate and analyze your issue if you need help.
But with that said, you can use an external build environment. And if you were missing the LINQ package, you should get a compiler error from the "using System.Linq;
" directive.