Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Linq - When using FirstOrDefault, make sure to check for null result
//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 Thing { public string Name {get; set;} public decimal Value {get; set; } } public class Program { public static void Main(string[] args) { List<Thing> _myList = new List<Thing>() { new Thing() {Name = "A", Value = 1}, new Thing() {Name = "B", Value = 2} }; decimal myVal = _myList.FirstOrDefault(t => t.Name == "C").Value; } } }
run
|
edit
|
history
|
help
0
sdcasdcasdcsadxcd
Queue with Queue Data type
D18
SHA tester
olution to problem #2 from projecteuler.net
Operators
Robot
Plt-D v.0.9.1
Linq-Where-Condition on a collection of anonymous types
congtodien