Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
C# is a multiparadigm, managed, garbage-collected object-oriented programming language created by Microsoft in parallel with the .NET platform
4
votes
Accepted
Is there a name for this in type theory? Specify that a value satisfies multiple interfaces ...
Scala allows this and calls the resulting type a Compound Type. Your example would look something like this in Scala:
def seekAndRead(stream: IReaderStream with ISeekable) {
stream.seek(5) // OK
…
2
votes
Alternatives to #if when polymorphism doesn't seem possible
Conditional compilation effectively creates multiple versions of the code base. That's exactly the purpose of version control branches.
The other alternative is put whatever code needs to vary in its …
5
votes
Accepted
When designing a data structure, should I implement very inefficient operations for convenie...
Addition of many elements to the end is O(m + logn), where m is the number of elements to be added. These operations would be O(n + m), and if m = n then they are almost as fast as addition to the …
3
votes
Avoiding a large amount of overloads
From your comments it seems you have something like this:
Send(Data data, Address address, A a, B b, C c) { ... }
Send(Data data, Address address, A a, D d, E e, F f) { ... }
Send(Data data, Addres …
4
votes
Using struct to enforce validation of built-in type
This is fairly common in ML-style languages like Standard ML/OCaml/F#/Haskell where it's much easier to create the wrapper types. It provides you with two benefits:
It allows a piece of code to enfo …
5
votes
Accepted
Does laziness yield more race conditions?
Your first link does address the issue - it's laziness combined with side effects that is problematic, because the order of side effects matters.
For pure computations, the main thing that changes is …
2
votes
Extending a struct. Using helper classes rather than composition
Helper classes can be an organizational anti-pattern when you have some generic Helpers file where you dump every single miscellaneous static function all your projects have ever used. Don't do that. …
7
votes
Am I wrong in thinking that needing something like AutoMapper is an indication of poor design?
There is a deeper issue here: the fact that C# and Java insist most/all types must be distinguishable by name rather than structure: e.g. class MyPoint2D and class YourPoint2D are separate types even …
95
votes
Why was C# made with "new" and "virtual+override" keywords unlike Java?
It was done because it's the correct thing to do. The fact is that allowing all methods to be overridden is wrong; it leads to the fragile base class problem, where you have no way of telling if a cha …
-1
votes
Is there a good way to communicate the intent that a class only contains referentially trans...
I don't do much C# development but it seems to me you could define an attribute and apply it to all such classes. You could then give a thorough description of what restrictions that imposes on classe …
3
votes
How to enforce implementation of interface to behave a certain way
You can't. That's the thing about interfaces - they allow anyone to implement them at any time. There's an infinite number of potential implementations for your interface, and you can't force any of t …
0
votes
Relative encapsulation design
A simple solution would be to make them immutable and produce new world objects for the next world state. This gives the Level complete control over the world's state without allowing objects to inter …
0
votes
Gathering IP address and workstation information; does it belong in a state class?
It seems to me on 2nd through that it's meant to be a class that should hold state, and not know how to call out to the .NET Framework to find info.
Spot on. What you have is just a data containe …
1
vote
How To Invoke A Method When It's Class is Accessed (Any Method) - "OnClassEnter"
Disclaimer: My C# experience is probably less than 8 hours total so the syntax that follows may not be accurate.
So, somewhere between Device1.Method1; and Device2.Method3; When switching between …
1
vote
Segregating interfaces/concerns to a tree
It seems like the presentation and data should be defined in separate classes, but I can't think of a good way to do this while maintaining the ability to traverse the tree. Any suggestions?
The …