Thursday, December 17, 2009

K-MUG Session on 19th Saturday at Technopark, Trivandrum





next K-MUG User group session on 19th Saturday. More details can be located under event page of Kerala Microsoft Users Group (K-MUG) web site.

Wednesday, June 10, 2009

How to Scale your entire App and its Elements to your Browsers Size

Wow, Today I found the answer of the question "How to Scale your entire App and its Elements to your Browsers Size?" And the answer of the question "How to Scale your entire App and its Elements to your Browsers Size?" And the answer provided to me is by the silverlight 2.0. I always wonder that how can i scale my application to different browser sizes... and to different screen resolutions I found some PHP sites which were scalable according to the browser size but was unable to handle the same in my ASP.net applications... I have Hear-ed a lot about the silverlight and its applications but never give a thought to it and now finally when my client needs the scalable sites then i have no other option left with me i have to search it and thought to go ahead with silverlight and today only i get all the essentials for the silverlight and started to find the solution and to my wonders i found the solution so simple and easy... Here I would like to share it with you all...

Saturday, April 18, 2009

Fast clean way to check if an array contains particular element in C# 3.0

A good to know that really fast and the most elegant way to check if an array contains particular element in C# 3.0 seems to be using Contains() extension method.

using System;
using System.Diagnostics;
using System.Linq;
namespace Test
{
class Program
{
static void Main(string[] args)
{
int[] data = new int[10000000];

Random rand = new Random();
for (int i=0; i{
data[i] = rand.Next();
}

int value = data[data.Length/2];
ContainsViaForEachLoop(data, value);
ContainsViaForLoop(data, value);
ContainsViaContainsExtMethod(data, value);
ContainsViaAnyExtMethod(data, value);
Stopwatch watch = new Stopwatch();
watch.Start();
if (ContainsViaForEachLoop(data, value))
{
watch.Stop();
Console.WriteLine("foreach loop search:\t\t{0} ms",
watch.ElapsedMilliseconds);
}
watch.Reset();
watch.Start();
if (ContainsViaForLoop(data, value))
{
watch.Stop();
Console.WriteLine("for loop search:\t\t{0} ms",
watch.ElapsedMilliseconds);
}
watch.Reset();
watch.Start();
if (ContainsViaContainsExtMethod(data, value))
{
watch.Stop();
Console.WriteLine("Contains() method search:\t{0} ms",
watch.ElapsedMilliseconds);
}
watch.Reset();
watch.Start();
if (ContainsViaAnyExtMethod(data, value))
{
watch.Stop();
Console.WriteLine("Any() method search:\t\t{0} ms",
watch.ElapsedMilliseconds);
}
}
public static bool ContainsViaForEachLoop(int[] data, int value)
{
foreach (int i in data)
{
if (i == value)
{
return true;
}
}
return false;
}
public static bool ContainsViaForLoop(int[] data, int value)
{
for (int i=0; i{
if (data[i] == value)
{
return true;
}
}
return false;
}
public static bool ContainsViaContainsExtMethod(int[] data, int value)
{
return data.Contains(value);
}
public static bool ContainsViaAnyExtMethod(int[] data, int value)
{
return data.Any(i => i == value);
}
}
}

Accessing the properties of the event sender

I was Having two Controls in the Sender one dropdown list and other is a Radio Button List
the Access the object Sender

if (sender is DropDownList)
hiddenSelectedOptionID.Value = ddlOptions.SelectedValue;
if (sender is RadioButtonList)
hiddenSelectedOptionID.Value = rblTypes.SelectedValue;