All Questions
Tagged with language-design .net
49 questions
4
votes
0
answers
79
views
Is there a technical reason C# doesn't have a property setter shorthand similar to object initializer, or is it just a design choice?
If I have an already-created object (e.g. a control on a form) and I want to initialize a number of properties, I have to do this:
myObj.Details.Color = Colors.Red;
myObj.Details.Name = "My Object";
...
12
votes
3
answers
3k
views
Implicit conversion from char to single character string
First of all: I know how to work around this issue. I'm not searching for a solution. I am interested in the reasoning behind the design choices that led to some implicit conversions and didn't lead ...
0
votes
0
answers
1k
views
Why explicit interface implementation [duplicate]
What is the rationale behind explicit interface implementation?
What problem/feature does it solve?
Or, put in other words, why .Net designer inserted explicit interface implementation in the ...
1
vote
1
answer
340
views
Why does conditional methods must have a return type of void?
We were writing some global exception handler for our API and we need to execute certain method only in Debug configuration and obviously conditional method is possible solution.
What I saw however ...
7
votes
3
answers
136
views
What is the use of field initialisers in .NET(apart from readability)?
I am just trying to learn about field initializers. I ran into the error - field initializers cannot use non static field, method or prop. While hunting an answer for this I came across THIS post.
...
3
votes
2
answers
479
views
Term to call a function with empty parameter
In functional programming, what is the correct name to call a function that accepts no arguments? For example:
// 2 types of execute functions
type Function =
| UnitFunction of (unit -> unit)
...
3
votes
1
answer
91
views
Why does F# fail to support extending system type with its type abbreviation?
For example, if I try to extend int, with int is not the true name of the type, this code will fail:
type int with
member this.IsEven = this % 2 = 0
I must use System.Int32 instead:
type System....
2
votes
1
answer
553
views
Does System.ValueType inherit from System.Object or no?
I am confused a bit, maybe I am looking at the wrong places, please enlighten me!
I am looking at msdn's descpription of System.ValueType class, and it is showing the following in the Inheritance ...
1
vote
3
answers
307
views
Implicit chain constructor in .NET [closed]
Why is there no implicit chain constructor to the base class?
What I mean? Let's look at the following classes:
class Person
{
public String Name { get; set; }
public Person(string name)
...
4
votes
1
answer
447
views
Why Debug is different to Release in this specific and very simple case? [duplicate]
... and by different I don't mean performance, debug-ability candies and so on, I am meaning different programs (programs that for the same input gives different outputs).
Take the following program:
...
6
votes
1
answer
1k
views
Design reason why .NET does not have a conceptual (Fatal-)Error exception type? [closed]
Preliminary note:
This question is not intended to bash on .NET, nor is intended to wage a discussing war if there is such a thing as a "Fatal Exception" - Java's designers clearly thought there are,...
0
votes
2
answers
89
views
Preventing inheritance of static member
Base:
public abstract class systemClient : IDisposable
{
public static List<systemClient> Collection = new List<systemClient>();
[...]
}
derived class
public class station : ...
2
votes
2
answers
240
views
Why is TimeSpan not a typedef of Int64?
System.TimeSpan class only has one non-static private field and that is
internal long _ticks;
So it only keeps ticks and performs all operations (Add, Subtract, TotalSeconds ...) and overloads ...
7
votes
4
answers
1k
views
Is it possible to add keyword to C# or VB.NET?
I know it might not be worth it but just for education purposes I want to know if there is a way to inject your own keywords to .NET languages.
For example I thought it's good to have C++ asm keyword ...
14
votes
2
answers
17k
views
C# readonly vs Java final
In Java, final means a variable can only be assigned to once, but that assignment can happen anywhere in the program. In C#, readonly means a field can only be assigned in a constructor, which, IMO, ...