Sunday, January 11, 2009

Beginning Lamda Expression in C#


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Lamda_expresion_test
{
class Program
{
public delegate int ChangeInt(int x);
public delegate int SummingInt(int x, int y);

static void Main(string[] args)
{
int[] numbers = new[] { 3, 8, 4, 6, 1, 7, 9, 2, 4, 8 };
int[] negetiveNumbers = new[] { -1,-2,-3,-4,-5,-6};

int count = numbers.Count(x => x % 2 == 0);//x % 2==1 for odd

Console.WriteLine("Total even numbers: {0}\n",count);


Console.Write("Numbers greater than 6: ");
foreach (int a in numbers.Where(p => p > 6))
Console.Write(" {0}",a);


Console.WriteLine();

//// using delegate...reducing code

ChangeInt doubleInt = delegate(int x) { return x * 2; };
Console.WriteLine(doubleInt(12));

//using Lamda Expression code more reduced
ChangeInt delgate = x => x * 2;
Console.WriteLine(delgate(12));

//Lamda expression on two parameters....
SummingInt summing = (x, y) => x + y;
Console.WriteLine(summing(12,100));

// More complex operations......
Console.WriteLine("Numbers between 3 and 8: ");
foreach (int i in numbers.Where(x => x>=3 && x<=8))
 Console.Write(" {0}",i); 

Console.WriteLine(); 
//same as previous expression...... 
// we can make some codition like following.... 

foreach (int i in numbers.Where( 
x =>
{
if (x >= 3 && x <= 8) 
return true; 
else return false; 
} )) 
Console.Write(" {0}", i);
 Console.WriteLine(); 
}
 
}
}

Sunday, December 14, 2008

Graphical problem in IE 8 Beta version

There is some graphical problem i have faced in Internet Explorer 8 Beta version. I do not why this problem is occuring. Bu i have noticed that when i scroll or making some quick page up/down this problem occurs. I am giving a snapshot of its version and the problem:



Version:





Problem:


Saturday, November 29, 2008

No xaml designer in vs2008 Team System

I have faced the problem after installing vs2008 team system, there was no xaml design view & no graphical toolbox. I have repaired & reinstalled but problem was still occurring.....

Finally i got the solution from a forum. I m gonna make it clear

1. Close vs2008 team system if it is open.
2. Go to: start menu>all programs>Microsoft Visual Studio 2008> Visual Studio Tools> Visual Studio 2008 Command Prompt.
3. Write on the command prompt: devenv/resetskippkgs
4. Then open a wpf solution & right click a .xaml file and select open with, u will appear a dialog. U should set windows presentation foundation designer as default designer.

Now everything is right.

Monday, November 24, 2008

Sending Mail using your gmail account

c# source code u can use it and can develop ur own mail sender

System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();

System.Net.NetworkCredential cred = new System.Net.NetworkCredential("yourid@gmail.com", "yourpwd");

mail.To.Add("acme@acme.com");
mail.Subject = "subject";

mail.From = new System.Net.Mail.MailAddress("yourid@gmail.com");
mail.IsBodyHtml = true;
mail.Body = "message";

System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com");
smtp.UseDefaultCredentials = false;
smtp.EnableSsl = true;
smtp.Credentials = cred;
smtp.Port = 587;
smtp.Send(mail);

Saturday, November 15, 2008

Dmitri Gaskin 12yrs genius...

Dmitri Gaskin is a very talented boy of only 12yrs.....follow this link and see this little boy is presenting on JQUERY infront of google employee.....

http://www.youtube.com/watch?v=8mwKq7_JlS8

PC Magazine Tips and Solutions

PC World: Latest Technology News

PCWorld.com - Most Popular Downloads of the Week