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
8 changes: 8 additions & 0 deletions EnumsLinq/Enums/Enums.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>

</Project>
34 changes: 34 additions & 0 deletions EnumsLinq/Enums/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System;

namespace Enums
{
class Program
{
static void Main(string[] args)
{
DaysWithNumbers myBirthday = DaysWithNumbers.Friday;
Console.WriteLine("Hello World!");
// foreach (var item in Enum.GetValues(typeof(Days)))
// {
// System.Console.WriteLine(item);
// }
foreach (var item in Enum.GetValues(typeof(DaysWithNumbers)))
{
System.Console.WriteLine(item);
}
if (myBirthday == DaysWithNumbers.Friday)
{
System.Console.WriteLine();
}

}
enum Days
{
Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday
}
enum DaysWithNumbers
{
Monday = 1, Tuesday = 2, Wednesday = 3, Thursday = 4, Friday = 5, Saturday = 6, Sunday = 7
}
}
}
8 changes: 8 additions & 0 deletions EnumsLinq/EnumsPractice/EnumsPractice.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>

</Project>
32 changes: 32 additions & 0 deletions EnumsLinq/EnumsPractice/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;

namespace EnumsPractice
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
foreach (var item in Enum.GetValues(typeof(Months)))
{
System.Console.WriteLine(item);
}
}
enum Months
{
January, February, March, April, May, June, July, August, September, October, November, December
}
Point point1 = new Point(0, 1);
Point point2 = new Point(2, 2);
public struct Point
{
public int X { get; set; }
public int Y { get; set; }
public Point(int x, int y)
{
this.X = x;
this.Y = y;
}
}
}
}
8 changes: 8 additions & 0 deletions EnumsLinq/Linq/Linq.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>

</Project>
48 changes: 48 additions & 0 deletions EnumsLinq/Linq/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Linq;

namespace StudentList
{
public class Program
{
public static void Main()
{
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;
}
}
15 changes: 14 additions & 1 deletion Linq/Linq.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
using System;
using System.Linq;

namespace Linq
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");

var source = new int[] { 1, 2 };
var results =
from i in source
select i;

int total = source.Where(x => true).Select(Square).Sum();
Console.WriteLine(total);

}
public static int Square(int value)
{
return value * value;
}
}
}