Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
DB Search
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { Database db = new Database(); Item i1 = new Item("Shoes", "Clothing", 49.99m, DateTime.Now); Item i2 = new Item("Shirt", "Clothing", 9.99m, DateTime.Now); Item i3 = new Item("Pants", "Clothing", 39.99m, DateTime.Now); Item i4 = new Item("Socks", "Clothing", 19.99m, DateTime.Now); Item i5 = new Item("Ties", "Clothing", 5.99m, DateTime.Now); db.items.Add(i1); db.items.Add(i2); db.items.Add(i3); db.items.Add(i4); db.items.Add(i5); IEnumerable<Item> search = db.SearchDatabase("Shoes"); foreach (Item i in search) { Console.Write(i.ItemId.ToString() + ", "); Console.Write(i.Name + ", "); Console.Write(i.Category + ", "); Console.Write(i.Price.ToString() + ", "); Console.Write(i.DateBought.ToString() + ", "); } } } public class Database { public List<Item> items; public Database() { this.items = new List<Item>(); } public IEnumerable<Item> SearchDatabase(string name) { // Open connection to database with using statement name = name.ToUpper(); IEnumerable<Item> foundItems = this.items.Where(i => i.Name == name).Select(n => n); return foundItems; } } public class Item { public Guid ItemId { get; set; } public string Name { get; set; } public string Category { get; set; } public decimal Price { get; set; } public DateTime DateBought { get; set; } public Item() { } public Item(string name) { } public Item(string name, string cat, decimal price, DateTime date) { ItemId = new Guid(); Name = name.ToUpper(); Category = cat.ToUpper(); Price = price; DateBought = date; } } }
run
|
edit
|
history
|
help
0
multiplyarr
Code1
dfdfdff
asdfsdgghjghkhj
2 ushort remix to 1 int
Time diff with date list
EqualityComparer
hypotenuse calculator
X o X
code1