Jul 7 2006

Microsoft Private Folder 1.0

Category: General | GeneralBil@l @ 11:29

   Microsoft released a new utility to password-protect your folder. This is the description from the Microsoft site:

Microsoft Private Folder 1.0 is a useful tool for you to protect your private data when your friends, colleagues, kids or other people share your PC or account. With this tool, you will get one password protected folder called 'My Private Folder' in your account to save your personal files. Download and have your private folder today!

The following hardware and software are required to run Microsoft Private Folder 1.0:

  • Microsoft Windows XP Home Edition, Professional Edition and Media Center Edition with SP2
  • Super VGA (800 x 600) or higher-resolution video adapter and monitor

Please note: Microsoft Private Folder 1.0 is provided specifically for genuine Windows customers, and requires genuine Windows validation in order to download. The software is free, and does not come with product support.

You can download the utility from: Microsoft Private Folder 1.0

Regards

Tags: ,

Jul 7 2006

Provider ToolKit Configuration Utility - Part 2

Category: ASP.NET 2.0 - GeneralBil@l @ 09:47

In a previous post, Provider ToolKit Configuration Utility, I published a small utility that helps you create all the needed files when you are building a new Service Provider Model.

In this post, I have upgraded that utility to allow you to create Providers not only related to Data Sources but rather to other APIs. Sometimes, we might need to create a provider that talks to a third-party API, which is in this case neither an Oracle, SQL Server, Microsoft Access, etc ...

In addition, the Namespace TextBox has been increaded in width to allow you to use long namespaces and at the same time be able to see it.

You can download the new version from the Files section above.

Hope this helps,

Regards

Tags:

Jul 6 2006

Parameter Types in C#

Category: General | GeneralBil@l @ 08:35

I read a nice article this morning, wanted to share with you, it is an old and every day article I guess. The article is titled: Parameter passing in C#. It explains in details the different parameter types we have in C#. So I will be just summarizing the ideas mentioned there!

In .NET we have mainly two types: reference types and value types. Reference types mainly hold a reference to an object, while a value type holds the data itself.

For example,

public void myMethod (StringBuilder mySB)
{
        mySB = null;
}

StringBuidler sb = new StringBuilder();
sb.Append("Hello World");
myMethod(sb);
Console.WriteLine(sb);


In this example, we created a reference called sb to a StringBuilder and appended some data, then called the myMethod and passing to it the value of sb and not sb itself and the value of sb in this case is a reference to the StringBuilder object. myMethod would now create a new instance of StringBuilder (as a new storage location) whose value is the value of the passed parameter and hence mySB points to the same StringBuilder object. myMethod then sets the mySB to null which means that the value of the instance created within the method is set to null, and hence when we print out the value of sb, it will be Hello World. I hope you were able to see the idea here which is that, we passed a reference to an object and not the object itself.

However, we can still see the value type in .NET in this example with a small varaiation.

public void myMethod (StringBuilder mySB)
{
        mySB.Append("World");
}

StringBuidler sb = new StringBuilder();
sb.Append("Hello ");
myMethod(sb);
Console.WriteLine(sb);
The same example as above, but within the body of the method, we have appended data to the same reference object. When we print out the value of sb it will be "Hello World". Remember, both instance created refere to the same StringBuilder object and hence when you update the value or data inside the object through one reference, the update will be seen by all objects refering to that StringBuilder object. 

We have 4 different types of parameters in C#:

  1. Value Parameters
    Value parameters hold the data itself. When passed to a method, a new storage location is being created in memory. An example illustrates this type:

    public void myMethod (int myInt)
    {
            myInt = 10;
    }
    
    int newInt = 50;
    myMethod(newInt);
    Console.WriteLine(newInt);
    Since the simple data types such as int, double, character are passed by value, the method myMethod will update the current value of newInt and return it back tobe 10.
  2. Reference Parameters
    By default, classes, delegates, interfaces, arrays, etc .. are passed as a reference. However, sometimes you need to pass not only the reference to an object, but rather the whole object. Check this example:
    public void myMethod (ref StringBuilder mySB)
    {
            mySB = null;
    }
    
    StringBuidler sb = new StringBuilder();
    sb.Append("Hello ");
    myMethod(ref sb);
    Console.WriteLine(sb);
    In this example, we have used the ref keyword which is required when we want to pass a variable by ref. Notice that when we pass a parameter to a method preceeded by ref keyword, we are not passing the value of sb (which is a reference to StringBuilder object) but rather the object itself "sb". myMethod won't create a new storage location but rather use the same storage location of sb, so when it set mySB to be null, means that it is setting the reference itself of sb to null, which means that sb now is null and doesn't refer to any StringBuilder object.
  3. Output Parameters
    Output parameters work much like the ref keyword. You pass a parameter with the out keyword, the calling method would fill out some data inside its body, and the updated data will be reflected outside the method. An example clarifies it more:
    public void myMethod (out int myInt)
    {
            myInt = 10;
    }
    
    int newInt;
    myMethod(out newInt);
    Console.WriteLine(sb);
    

  4. Array Parameters
    Array parameters allows you to pass a variable number of parameters to a method.
    public void myMethod (params int[] myInts)
    {
            foreach(int x in myInts)
            {
                    Console.WriteLine(x + " ");
            }
    }
    
    // Either you pass an array
    int[] newInts = {1,2,3};
    myMethod(newInts);
    
    // Or you send seperate parameters
    myMethod(3,5,7,8);
    

Hope you found my post helpful.

Regards

Tags: ,