Multiple Inheritance in C#

Since multiple inheritance is bad (it makes the source more complicated) C# does not provide such a pattern directly. But sometimes it would be helpful to have this ability. C# and the .net CLR have not implemented MI because they have not concluded how it would inter-operate between C#, VB.net and the other languages yet, … Read more

What does question mark and dot operator ?. mean in C# 6.0?

It’s the null conditional operator. It basically means: “Evaluate the first operand; if that’s null, stop, with a result of null. Otherwise, evaluate the second operand (as a member access of the first operand).” In your example, the point is that if a is null, then a?.PropertyOfA will evaluate to null rather than throwing an exception – it will then compare that null reference with foo (using string’s == overload), … Read more

Error: “Cannot modify the return value” c#

This is because Point is a value type (struct). Because of this, when you access the Origin property you’re accessing a copy of the value held by the class, not the value itself as you would with a reference type (class), so if you set the X property on it then you’re setting the property on the copy and then discarding it, leaving … Read more

How can I find a specific element in a List?

Use a lambda expression Note: C# has a built-in syntax for properties. Instead of writing getter and setter as ordinary methods (as you might be used to from Java), write value is a contextual keyword known only in the set accessor. It represents the value assigned to the property. Since this pattern is often used, C# … Read more

Why is Dictionary preferred over Hashtable in C#?

For what it’s worth, a Dictionary is (conceptually) a hash table. If you meant “why do we use the Dictionary<TKey, TValue> class instead of the Hashtable class?”, then it’s an easy answer: Dictionary<TKey, TValue> is a generic type, Hashtable is not. That means you get type safety with Dictionary<TKey, TValue>, because you can’t insert any random object into it, and you don’t have to cast the … Read more

LEFT OUTER JOIN in LINQ

How to perform left outer join in C# LINQ to objects without using join-on-equals-into clauses? Is there any way to do that with where clause? Correct problem: For inner join is easy and I have a solution like this but for left outer join I need a solution. Mine is something like this but it’s not working where JoinPair is a … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)