Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Linq FirstOrDefault() null check in c#
//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) { try{ //Your code goes here PlayerSettingsResponsible objPlayer = new PlayerSettingsResponsible(); objPlayer.Designation="DesigOne"; objPlayer.IdPlayerDeviceSettingsType=1;//Change equal to 2 gives null objPlayer.Value="ValueOne"; List<PlayerSettingsResponsible> objPlayerList = new List<PlayerSettingsResponsible>(); objPlayerList.Add(objPlayer); PlayerSettingsResponsible objPlayerSearch = objPlayerList.FirstOrDefault(r => r.IdPlayerDeviceSettingsType != null && r.IdPlayerDeviceSettingsType == 1); if(objPlayerSearch == null) { Console.WriteLine("Null Object"); return; } string sValue = objPlayerSearch.Value; Console.WriteLine(sValue); } catch(Exception e){Console.WriteLine("Exception: "+e.Message);} } } public class PlayerSettingsResponsible { public string Designation { get; set; } public int? IdPlayerDeviceSettingsType { get; set; } public string Value { get; set; } } }
run
|
edit
|
history
|
help
0
bla bla
Rotate array to the right of a given pivot
C# practice
bubbleSort
.heap sort
a
time
Problem: rstring
Intuit // C# // Lecture_4 // Laba_#2
Is String a Palindrome