tagged [language-features]

Calling methods inside if() - C#

Calling methods inside if() - C# I have a couple of methods that return a bool depending on their success, is there anything wrong with calling those methods inside of the IF() ? Method2() doesn't nee...

Combined post-operators?

Combined post-operators? We're all familiar with the pre- and post-increment operators, e.g. and the "combined operators" which extend this principle: I've often had a need for a 'post-combined operat...

What's the difference between interface and @interface in java?

What's the difference between interface and @interface in java? I haven't touched Java since using JBuilder in the late 90's while at University, so I'm a little out of touch - at any rate I've been w...

C# method call with parameter name and colon

C# method call with parameter name and colon I've begun to notice at times when I'm making method calls in C# that the names of the parameters for the method I'm calling will show up in the intellisen...

10 Mar at 16:25

Why was constness removed from Java and C#?

Why was constness removed from Java and C#? I know this has been discussed many times, but I am not sure I really understand Java and C# designers chose to omit this feature from these languages. I am...

Why Doesn't C# Allow Static Methods to Implement an Interface?

Why Doesn't C# Allow Static Methods to Implement an Interface? Why was C# designed this way? As I understand it, an interface only describes behaviour, and serves the purpose of describing a contractu...

6 Jul at 07:14

How do you force constructor signatures and static methods?

How do you force constructor signatures and static methods? You can't obviously use interfaces for this, and I know that it will have a limited usage. One instance in which I do find it useful is when...

What is the tilde (~) in the enum definition?

What is the tilde (~) in the enum definition? I'm always surprised that even after using C# for all this time now, I still manage to find things I didn't know about... I've tried searching the interne...

Any chances to imitate times() Ruby method in C#?

Any chances to imitate times() Ruby method in C#? Every time I need to do something times inside an algorithm using C# I write this code ``` for (int i = 0; i

18 May at 01:45

Why doesn't VB.NET 9 have Automatic Properties like C# 3?

Why doesn't VB.NET 9 have Automatic Properties like C# 3? Would having a nice little feature that makes it quicker to write code like Automatic Properties fit very nicely with the mantra of VB.NET? So...

Can you create private classes in C#?

Can you create private classes in C#? This is a question for the .NET philosophers: It is my understanding that Microsoft consciously denied use of private classes in C#. Why did they do this and what...

28 Nov at 20:31

JavaScript hashmap equivalent

JavaScript hashmap equivalent As made clear in update 3 on [this answer](https://stackoverflow.com/questions/367440/javascript-associative-array-without-tostring-etc#367454), this notation: does not a...

How does "this" keyword work within a function?

How does "this" keyword work within a function? I just came across an interesting situation in JavaScript. I have a class with a method that defines several objects using object-literal notation. Insi...

Why are private fields private to the type, not the instance?

Why are private fields private to the type, not the instance? In C# (and many other languages) it's perfectly legitimate to access private fields of other instances of the same type. For example: As t...

c# switch statement more limited than vb.net 'case'

c# switch statement more limited than vb.net 'case' I was reading an interesting article [here](http://visualstudiomagazine.com/Articles/2011/05/01/pfcov_Csharp-and-VB.aspx?Page=2) and it made an inte...

Are there any disadvantages of using C# 3.0 features?

Are there any disadvantages of using C# 3.0 features? I like C# 3.0 features especially lambda expressions, auto implemented properties or in suitable cases also implicitly typed local variables (`var...

23 Dec at 11:0

C# Null propagating operator / Conditional access expression & if blocks

C# Null propagating operator / Conditional access expression & if blocks The [Null propagating operator / Conditional access expression](https://roslyn.codeplex.com/discussions/540883) coming in [c#-6...

4 Sep at 13:38

Volatile fields in C#

Volatile fields in C# From the specification 10.5.3 Volatile fields: --- The type of a volatile field must be one of the following: - A reference-type.- The type byte, sbyte, short, ushort, int, uint...

25 Feb at 03:41

How to hide (remove) a base class's methods in C#?

How to hide (remove) a base class's methods in C#? The essence of the problem is, given a class hierarchy like this: ``` class A { protected void MethodToExpose() {} protected void MethodToHide(...

"using" construct and exception handling

"using" construct and exception handling The "[using](http://msdn.microsoft.com/en-us/library/yh598w02.aspx)" construct looks incredibly handy for situations that require both beginning and separated ...

C# internal VS VBNET Friend

C# internal VS VBNET Friend To this SO question: [What is the C# equivalent of friend?](https://stackoverflow.com/questions/204739/what-is-the-c-equivalent-of-friend), I would personally have answered...

Consider a "disposable" keyword in C#

Consider a "disposable" keyword in C# What are your opinions on how disposable objects are implemented in .Net? And how do you solve the repetitiveness of implementing IDisposable classes? I feel that...

Problem understanding C# type inference as described in the language specification

Problem understanding C# type inference as described in the language specification The [C# language specification](http://www.microsoft.com/downloads/en/details.aspx?familyid=DFBF523C-F98C-4804-AFBD-4...

C#: Property overriding by specifying the interface explicitly

C#: Property overriding by specifying the interface explicitly While attempting to override the explicit interface implementation of the `ICollection.IsReadOnly` property from the `Collection` class, ...

Why C# doesn't implement indexed properties?

Why C# doesn't implement indexed properties? I know, I know... Eric Lippert's answer to this kind of question is usually something like "". But still, I'd like a better explanation... I was reading [t...