Tag Info

New answers tagged

8

In the first program, you called Array.Reverse, a static method of the Array class that reverses the array in-place. In your second program, you called Enumerable.Reverse, an extension method that works on any kind of enumerable. As an array is a kind of enumerable, it does work on arrays. But it does not do in-place reversion, but instead returns a new ...


0

The information here is a bit scarce and I don't have enough reputation to ask for more in a comment, but I'll give it a go anyway. First of all (if you haven't already) you may want to check out SOLID. Follwing these rules will give your sofware a good dependency structure. A nice dependency structure is key to being able to swap modules in and out. (And ...


3

I guess the "correct" way to do this is to have a protected constructor on the base class which requires the state name as a parameter. public abstract class State { private readonly string _name; protected State(string name) { if(String.IsNullOrEmpty(name)) throw new ArgumentException("Must not be empty", "name"); ...


2

Your requirements are a contradiction: I'm trying to create a String property for each State called StateName. vs. But I don't need to implement all of that in each State. There's no language feature that allows you to force the existence of a member in only a few sub classes. After all, the point of using a super class is to rely on the fact ...



Top 50 recent answers are included