Tags » Csharp

Confusing errors for a confusing feature, part two

Last time I gave you the challenge to find a case where the same simple name means two different things, without introducing a new local/parameter/range variable into scope, that produces an error. 347 more words


Confusing errors for a confusing feature, part one

There’s a saying amongst programming language designers that every language is a response to previous languages; the designers of C# were, and still are, very deliberate about learning from the mistakes and successes of similar languages such as C, C++, Java, Scala and so on. 1,122 more words


Inlines and Run in TextBlock does not follow Language override

If you want to localize your application you generally override the LanguageProperty with your desired language:

    new FrameworkPropertyMetadata(XmlLanguage.GetLanguage("de-DE")));

As stated in the documentation every control should now use the – in this case – German culture. 238 more words


Using AutoMapper : Getting Started

Read full article on Falafel blog

I have often seen developers use the LINQ SELECT statement to create a new instance of one class from an existing instance of another class. 75 more words


SDN event september 2014

The SDN – Software Development Network – is a special interest group for dutch developers. Four times a year they organise an event where people present and talk about their passion. 424 more words

Windows Azure

Change SharePoint group permissions from code

Is not especially elegant, just “quick and dirty” :)

public static void ChangePermissions(SPSecurableObject subject, SPPrincipal principal, SPRoleType roleType)
    SPRoleDefinition roleDefinition = null;
    SPRoleAssignment roleAssignment = subject.RoleAssignments.GetAssignmentByPrincipal(principal);

    if (roleAssignment != null && subject != null)
        switch (subject.GetType().Name)
            case "SPList":
                if (!((SPList)subject).HasUniqueRoleAssignments)
                roleDefinition = ((SPList)subject).ParentWeb.RoleDefinitions.GetByType(roleType);
            case "SPWeb":
                if (!((SPWeb)subject).HasUniqueRoleAssignments)
                    ((SPWeb)subject).BreakRoleInheritance(true, false);
                roleDefinition = ((SPWeb)subject).RoleDefinitions.GetByType(roleType);
            case "SPItem":
                if (!((SPItem)subject).HasUniqueRoleAssignments)
                    ((SPItem)subject).BreakRoleInheritance(true, false);
                roleDefinition = ((SPItem)subject).Fields.List.ParentWeb.RoleDefinitions.GetByType(roleType);
            case "SPListItem":
                if (!((SPListItem)subject).HasUniqueRoleAssignments)
                    ((SPListItem)subject).BreakRoleInheritance(true, false);
                roleDefinition = ((SPListItem)subject).Fields.List.ParentWeb.RoleDefinitions.GetByType(roleType);

        if (roleDefinition != null)
… 73 more words

A galaxy var, var away

My current project has me writing C# scripts in Unity. Cool. I haven’t written C# for more than a decade. Today I was reviewing code, and noticed this line: 139 more words

Game Programming