:: :: ::

Archive for the 'C#' Category

New release of Generics.Net is on the way

Friday, June 29th, 2007

After its last release on October 16th 2006, I had received lots of email about library, its strength and its area of improvements, specially, the one prompting to kill the great G. Unfortunately I could only start working on improvements and suggestions some times ago, and fortunately its ready to be delivered anytime during next week :). It contains lots of new improvement, datastructure, algorithms… Great G prefix is no more.

By the way, don’t stop sending me suggestions, remember its yours and only yours library.

Recursive call with anonymous function

Sunday, October 29th, 2006
Whether you want to generate a dynamic function, write a dynamic algorithm or want to handle delegate inline, anonymous functions have always been at your service. However one area where in anonymous function lacking is, making a recursive call. Since it does not have function signature it’s not possible to make recursive call, at lease not directly. This entry shows you how to achieve that by utilizing some reflection API. Yes reflection, it’s always been there as your lifeguard ;).
    To understand the concept lets first create a simple recursive function to find a triangle.
Code: public int Triangle(int n)
{
  
return (n==1) ? 1 : n + Triangle(n-1);
}
Now we will use anonymous function to find a triangle. Please notice the code. It performs following steps to achive recursion.
  1. First finds the current performing method using top frame in the StackTrace.
  2. And then invokes it.
Code:
public delegate int TriangleDelegate(int n);  public static int AnonymousMethodTriangle(int n)
{
   TriangleDelegate triangle = delegate(int n)
   {
      //Find Method
      MethodBase method =
        
new StackTrace().GetFrame(0).GetMethod();
      return (n == 1) ? 1 : n +
         (
int)method.Invoke(null,new object[]
         {n-
1});//Invoke Method
    };
    return
triangle(n);
}
Pretty simple huh….

Generics.Net 0.2.0 out

Monday, October 16th, 2006
Verions 0.2.0 alpha of generics.net is out which contains following new stack oriented stuffs.
  • IGStack : Represents the interface for stack in generics.net.
  • GLinkedStack : Represents a linked list based stack.
  • GSynchronizedStack : A proxy stack class which makes IGStack based object synchronized.

Generics.net 0.1.0 released

Tuesday, October 10th, 2006

First version of generics.net, 0.1.0 has been released. Written in C# 2.0 generics.net is an object oriented library aims to provide complete generic solutions in terms of datastructures, algorithms and patterns. Current verion is in alpa and not completed, it is released to the community so thats it can be discussed and contributed. Project is hosted at codeplex.com, a microsoft’s community development site. Generics.net was visualized late in october 2004, then it was planned to be hosted at gotdotnet.com. Unfotunately it never happend. Anyway, now since project has been started it will reach to desired destination soon… Next version 0.2.0 will be released soon in the first half of the upcoming week ;).

Links

  • Generics.net project home