Skip to content

Instantly share code, notes, and snippets.

@k0stya
Last active December 14, 2015 08:48
Show Gist options
  • Save k0stya/5059924 to your computer and use it in GitHub Desktop.
Save k0stya/5059924 to your computer and use it in GitHub Desktop.
Reshaper highlights n.Value saying that there is a possibility of InvalidOperationException.
using System.Linq;
namespace Nullable
{
public class Nullable_Test
{
public void SumNullableNumbers()
{
int?[] numbers = new int?[10];
int sum = numbers.Where(n => n.HasValue).Sum(n => n.Value);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment