1
vote
4answers
697 views

Why do C# developers newline opening brackets? [closed]

I've spent most of the last several years working mainly with C# and SQL. Every programmer I've worked with over that time was in the habit of placing the opening brace of a function or control flow ...
6
votes
6answers
1k views

Would a “downcast if block” be a reasonable language feature?

Consider the following "if cast": class A { public void f1() { ... } } class B : A { public void f2() { ... } } A a = foo(); // might return A or B if ( a is B ) { // Inside block, ...
2
votes
3answers
455 views

Typical instantiation of new object - is there a way to avoid repetitious syntax?

When learning C# (and OO concepts more generally at the same time) something I found very distracting is exemplified by the following line: ExampleClass exampleObject = new ExampleClass(); It's the ...
2
votes
6answers
819 views

Stacking keywords on top of each other - poor style?

I have always wondered about this, especially in C/Java style languages. For example, consider the first 3 lines of this C# code: lock (serviceLock) using (var client = new ServiceClient()) try { ...
22
votes
4answers
5k views

What's the difference between implementing an Interface explicitly or implicitly?

In Visual Studio I can right-click on an interface and choose to Implement Interface, or Implement Interface Explicitly. public class Test : ITest { public string Id // Generated by Implement ...
6
votes
3answers
609 views

Is there a reason to prefer lambda syntax even if there is only one parameter?

List.ForEach(Console.WriteLine); List.ForEach(s => Console.WriteLine(s)); To me, the difference is purely cosmetic, but are there any subtle reasons why one might be preferred over the other?
25
votes
5answers
8k views

A practical use of “yield” keyword in C#

After almost 4 years of experience, I haven't seen a code where yield keyword is used. Can somebody show me a practical usage (along explanation) of this keyword, and if so, aren't there other ways ...
5
votes
4answers
727 views

Shouldn't the lazy evaluation/execution be syntactically differentiated from eager evaluation/execution in C#?

We know about the deferred execution or lazy evaluation features introduced in C#. But at times, people become confused with them. Because there is no significant difference. You can only know if you ...
28
votes
2answers
9k views

Why is VB so popular? [closed]

To me, Visual Basic seems clumsy, ugly, error-prone, and difficult to read. I'll let others explain why. While VB.net has clearly been a huge leap forward for the language in terms of features, I ...