§ January 26, 2007

Phalanger, PHP for .NET

I ran across an article on the code project about a PHP compiler / language extension for .NET.

PHP has an extension for .NET that allows you to use .NET resources in PHP code, but this allows you to use PHP from .NET, with support for native PHP API's as well as managed compilation. This project may end up making my article on nusoap & C# obsolete, though it should make writing web services in PHP as easy as it is in C#.

» Phalanger Home
» Code Project Article

Screen Shot in Visual Studio

Article Sections :: C # Articles :: Tech. Articles

  § July 29, 2006

The C# 3.0 language specification

I know I'm a bit late here, but better late than never.

I've been reading over some of the changes to C# for version 3. I had heard that v3 would be v2 with the addition of the new WPF, but looking over the new spec (well, fairly new anyway), there is quite a bit more.

Implicit types, method extensions, lambda expressions, object / collection initializers, and LINQ... C# is going to look really weird! So much for simplicity.

Implicit types (csharp meets vb or php) allow you to define the variable without a (or with an implied) type:
var foo = "hello";
var bar = 32;

so foo is implied to be of type string, and bar is implied to be of some numeric type.

Method extensions look very strange. Think of old dog learns new tricks meets operator overloading. Method extensions allow you to create "extension" methods for existing types:
public class Bar {
    string what = "hello";
    public string What { get { return what; } set { what = value; } }
    public Bar() {}
    public void Hello() { 

public static class Foo {
    public static void SayHelloToSteve(this Bar bar) {
        bar.What += " steve";
    public static void SayHelloToSomeone(this Bar bar, string who) {
        bar.What = who;

public class Program {
    static void Main(string[] args) {
        Bar b = new Bar();
        b.SayHelloToSomeone("Hello Bob!");

Notice that SayHelloToSteve() and SayHelloToSomeone(string s) are not member methods of the Bar class, but are invoked as if they were (by virtue of the Method extension defined in Foo that are available to Bar). This seems like a feature that will be abused to defeat inheritance (by adding reflection to the method extenstions to manipulate internal class memebers without inheriting and changing functionality of the object) that would otherwise look odd and ugly.

hello steve
Hello Bob!

At this point lambda expressions dont make much sense to me, but it seems its a way to define more than one method body in an anonymous method.

Object / collection initialization makes initialization a lot easier. I don't know if you've ever wanted to declare a new object inline inside a method, only to realize that you needed to set a few properties before it was used, well this is the answer to that:

myObject.Blah(new SomeObject() { PropertyA = 1, PropertyB = "dude", PropertyC = false });

Then there's LINQ: which feels something like SQL for C#.

feel free to download the spec here

Article Sections :: C # Articles :: Tech. Articles

  § December 2, 2005

Visual Studio .NET 2005 Troubleshooting Tool

I was having some troubles with the final release visual studio Team System. I've been using VS.NET 2005 on my home computer since the first previews were available on MSDN. I had installed and uninstalled each release of the IDE. I was experiencing problems viewing some of the docking window contents (entire panels loosing their contents, and were not able to be closed). I found A trouble shooting tool on Aaron Stebner's blog. I ran it, it found an orphaned beta assembly that was causing all the problems, and now I'm up and running without any problems...

Very Nice!
Article Sections :: Tech. Articles

  § September 6, 2005

Stupid .NET 1.1 Service Pack 1

Service pack 1 strikes again.

    using System;
    using System.Drawing;
    using System.IO;
    using System.Reflection;
    public class Resources {
        private Resources() {}
        public static Image LoadImageFromResource(string path) {
            Image i = null;
            using ( Stream s = 
                      Assembly.GetExecutingAssembly().GetManifestResourceStream(path) ) {
                if(s != null) i = Image.FromStream(s, true, true);
            return i;
This is part of a general use utility that I frequently use. An odd bug that came out of this is that the overloaded method

Image.FromStream(Stream, Boolean, Boolean)

was added in Service Pack 1 for .net v1.1 BUT NEVER DOCUMENTED!!!. Well, ok, that's not entirely true, It is documented... in v2.0 documentation... So if you wrote this in 1.1sp1 and deploy it to a machine with out sp1 you'll get a method not found exception when trying to load the image from stream using the above overload--non sp1 only has FromStream(Stream, Boolean)

Nothing like being incompatible with the same version of the framework eh?
Article Sections :: C # Articles :: Tech. Articles

  § June 15, 2005

C# 2 Language Specification

I've been reading over the new beta 2 C# specification lately. Good Read: Download it here

Cant wait until its production ready!

Article Sections :: C # Articles :: Tech. Articles
© 2003 - 2024 NullFX
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License