I recently saw this question regarding the use of methods that get passed delegates — specifically, the .NET 2 collection classes make use of this, like for example the List<T>
class, which takes a Predicate<T>
as a parameter to its Find
method. Now the question is how to make use of this method? How does the delegate know what to do when it’s called?
As I see it, there are two (good) approaches to this: using an anonymous method and using a separate class. I’m going to illustrate both …
I guess you know the way you can define aliases with the using statement:
using SWF = System.Windows.Forms;
Then you can use the shortcut SWF
to reference a type in the namespace. In C# 1, the syntax was like this:
SWF.Button button = new SWF.Button();
Obviously this could be ambiguous, because there could have been any kind of different identifier in scope called SWF. To get rid of this ambiguity, C# 2 introduced the ::
qualifier. So now you’ll write the sam …
This blog article explains that, and why, a late change to the implementation of nullable types is being made in the runtime, making nullables an intrinsic type. This solves the problems that many had reported when nullables were used in situations where boxing occurred, and where null comparisons were made involving generic types. Read the original article for the details, this is good news!
I just came upon this question in a newsgroup and had a quick look at the new classes that .NET 2 offers for access to the Windows file system ACLs and general system security information. In short, to get to the name of a user or group that’s the owner of a directory in the file system, you can use the following code:
DirectoryInfo directoryInfo = new DirectoryInfo(@"c:\Windows");
DirectorySecurity directorySecurity =
directoryInfo.GetAccessControl(AccessControlSections.Owner);
Id ...
I’m using Developer Express XtraBars in my .NET applications. With one of the latest releases, XtraBars also support the new skinning technology, which the website depicts quite inadequately but which takes the experience of an application based completely on DX controls to a new level visually. Now who would have thought that a package such as this would have grave deficiencies in other areas? Well, custom drawing is one such area.
Recently I wanted to create a simple bar item that would be a …
A while ago, I read a tiny note about this in somebody’s blog and I want to start off by apologizing to that somebody because for the life of me I can’t figure out who it might have been — so no reference here. Sorry about that. Anyway, I followed up on the original information and I thought it couldn’t hurt to pull peoples’ attention to this a bit more. So, the ??
operator: It’s an extension in C# 2.0 (find the specs here, this operator is explained on page 14, then end of chapter 19.5) and …
I just stumbled upon a funny problem related to the new .NET 2.0 attribute InternalsVisibleTo
in conjunction with a strong-named assembly. The situation is this: I have that assembly that exposes its internals to another assembly (for unit testing) using InternalsVisibleTo
.
Now I decided to sign that assembly with a strong name. Suddenly, I got the following error message at compile time: _Friend assembly reference ‘UnitTests’ is invalid. Strong-name signed assemblies must specify a public …
Many things change with the decision to work with purely object-oriented data in a specific situation. The outlook seems good: business processes and rules will be much easier to implement, completely typed data will be no problem at all and there’ll be no more structural problems trying to accomodate clumsy handling of records and rows in an otherwise OO application structure. There’ll be an object/relational mapping tool that takes care of all the persistence issues. There’s one thing though …