Iif equivalent in C#

C# has the ? ternary operator, like other C-style languages. However, this is not perfectly equivalent to IIf(); there are two important differences. To explain the first difference, the false-part argument for this IIf() call causes a DivideByZeroException, even though the boolean argument is True. IIf() is just a function, and like all functions all … Read more

.NET Core vs Mono

What is the difference between .NET Core and Mono? I found a statement on the official site that said: “Code written for it is also portable across application stacks, such as Mono.” My goal is to use C#, LINQ, EF7 and Visual Studio to create a website that can be ran/hosted on Linux. Someone told … Read more

Get single listView SelectedItem

Usually SelectedItems returns either a collection, an array or an IQueryable. Either way you can access items via the index as with an array: By the way, you can save an item you want to look at into a variable, and check its structure in the locals after setting a breakpoint.

Func vs. Action vs. Predicate [duplicate]

The difference between Func and Action is simply whether you want the delegate to return a value (use Func) or not (use Action). Func is probably most commonly used in LINQ – for example in projections: or filtering: or key selection: Action is more commonly used for things like List<T>.ForEach: execute the given action for … Read more

What should I use an IEnumerable or IList? [duplicate]

Generally speaking, you should try and use the least specific type that suits your purpose. IEnumerable is less specific than IList (IList implements IEnumerable) so unless you want something specific from IList (such as Count as you suggest, or perhaps Add, Delete, etc), I’d use IEnumerable. One benefit of remaining with IEnumerable is that you … Read more

“Use the new keyword if hiding was intended” warning

Your class has a base class, and this base class also has a property (which is not virtual or abstract) called Events which is being overridden by your class. If you intend to override it put the “new” keyword after the public modifier. E.G. If you don’t wish to override it change your properties’ name … Read more