Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions Linq/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/netcoreapp2.0/Linq.dll",
"args": [],
"cwd": "${workspaceFolder}",
// For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
"console": "internalConsole",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
,]
}
15 changes: 15 additions & 0 deletions Linq/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/Linq.csproj"
],
"problemMatcher": "$msCompile"
}
]
}
44 changes: 40 additions & 4 deletions Linq/Linq.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,48 @@
using System;
using System.Collections.Generic;
using System.Linq;

namespace Linq
namespace StudentList
{
class Program
public class Program
{
static void Main(string[] args)
public static void Main()
{
Console.WriteLine("Hello World!");
List<Student> students = new List<Student>();

students.Add(new Student("Chris", "123-456-7891", "123 Delany", -2990));
students.Add(new Student("Kevin", "512-222-2222", "435 Carolyn", -2500));
students.Add(new Student("Victoria", "512-827-8498", "701 Brazos St", 0));
students.Add(new Student("Luke", "555-555-5555", "451 Brody Ln", -500));

//your code here
IEnumerable<Student> negativeBalance = from currentStudent in students
where currentStudent.Balance < 0
select currentStudent;

Console.WriteLine("Students with a negative balance:");
foreach (Student currentStudent in negativeBalance)
{
Console.WriteLine(currentStudent.Name);
}

}
}

}

public class Student
{
public string Name { get; set; }
public string Phone { get; set; }
public string Address { get; set; }
public int Balance { get; set; }

public Student(string name, string phone, string address, int balance)
{
Name = name;
Phone = phone;
Address = address;
Balance = balance;
}
}