It’s been a while since we’ve had a reader question, so here’s one for you all. It’s not that I can’t solve this problem; it’s more that I’m wondering if there’s a more elegant solution.
The Problem: Given two dates, what’s the easiest way of determining if they fall in the same week?
Please submit your answers as a comment!
It’s been a while since anyone has posted a daily question, but here’s one to get y’all in the mood…
Given the following code:
public class BaseClass {
public BaseClass() : this("Base value") {
Console.WriteLine("Base: Empty");
}
public BaseClass(object value) {
Console.WriteLine("Base with value: {0}", value);
}
}
public class DerivedClass : BaseClass {
public DerivedClass() : this("Derived value") {
Console.WriteLine("Derived: Empty");
}
public DerivedClass(object value) : base(value) {
Console.WriteLine("Derived with value: {0}", value);
}
}
What will be printed to the console when a new DerivedClass object is created using the default DerivedClass constructor:
new DerivedClass();
First person to post the correct answer wins a prize consiting solely of that warm fuzzy feeling you get by being the first person to answer a question correctly.
A work colleague and I were discussing what we thought the best Visual Studio keyboard shortcut was.
The shortcut had to be a VS one and not that of a third party (eg. Resharper).
We came to the conclusion that Alt-Shift-Enter to enter into and out of Full Screen mode took 1st prize.
The shortcut to save - ctrl-s - is pretty handy too, but we decided this was not unique to VS and was more of a windows common-look-and-feel item.
What’s your favourite VS keyboard shortcut?
A daily question from a while back that had perplexed me for ages:
Q: In a DataBound control, what’s the difference between using a <%= %> block, and a <%# %> block?
Of course I actually did know the difference, and when I should use each one, but Bender summed up the correct answer the best:
A: You use a <%# %> block if you need access to the underlying DataSource of the repeating control (e.g. you need to access the DataItem with an Eval statement, or you need access to the Container element).
When you do not need to access the underlying DataSource, use a <%= %> block instead.