diff --git a/Linq/.vscode/launch.json b/Linq/.vscode/launch.json new file mode 100644 index 00000000..0fffa3f8 --- /dev/null +++ b/Linq/.vscode/launch.json @@ -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}" + } + ,] +} \ No newline at end of file diff --git a/Linq/.vscode/tasks.json b/Linq/.vscode/tasks.json new file mode 100644 index 00000000..77de61b2 --- /dev/null +++ b/Linq/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/Linq.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/Linq/Linq.cs b/Linq/Linq.cs index 6cabb44e..95c33a43 100644 --- a/Linq/Linq.cs +++ b/Linq/Linq.cs @@ -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 students = new List(); + + 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 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; + } }