Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
linq
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//Title of this code //Rextester.Program.Main is the entry point for your code. Don't change it. using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public enum ItemType { Sword, Shield } public class ShopItem { public int Cost { get ; set; } public string Name { get; set; } public ItemType Type { get; set; } } public class Program { public static void Main(string[] args) { ICollection<ShopItem> items = new List<ShopItem>(); items.Add(new ShopItem () { Cost = 5, Name = "A", Type = ItemType.Sword }); items.Add(new ShopItem () { Cost = 6, Name = "B", Type = ItemType.Shield }); items.Add(new ShopItem () { Cost = 6, Name = "C", Type = ItemType.Sword }); items.Add(new ShopItem () { Cost = 7, Name = "D", Type = ItemType.Sword }); items.Add(new ShopItem () { Cost = 3, Name = "E", Type = ItemType.Sword }); items.Add(new ShopItem () { Cost = 8, Name = "F", Type = ItemType.Shield }); var swords = from item in items where item.Type == ItemType.Sword orderby item.Cost descending select item; Console.WriteLine("Most Expensive sword: {0}", swords.First().Name); } } }
Show compiler warnings
[
+
]
Show input
fork mode
|
history
|
discussion