Monthly Archives: February 2009

Elements of Power Set

Write a program to print the elements of power set of a given set.   using System; using System.Collections.Generic; using System.Linq; using System.Text;   namespace PowerSet {     class Program     {         static void Main(string[] args)         {             … Continue reading

Posted in Information Technology | Leave a comment

Sub array having maximum sum

Problem: Given an array of positive and negative integers, return the sub array having maximum sum. Example: Given {1, -1, 2, 0, 1, -1}, the program should return {2, 0, 1}   using System; using System.Collections.Generic; using System.Linq; using System.Text; … Continue reading

Posted in Information Technology | Leave a comment

C# code to send an email using Microsoft Outlook Object Library

using System; using System.Reflection; using Outlook = Microsoft.Office.Interop.Outlook;   namespace SendMail {     public class Test     {         public static int Main(string[] args)         {             try             {                 // Create the Outlook application.                 Outlook.Application oApp = … Continue reading

Posted in Information Technology | Leave a comment

Monitoring file creation using FileSystemWatcher class

using System; using System.Collections.Generic; using System.Text; using System.IO; using System.Diagnostics;   namespace Test {     class Watcher     {         static void Main(string[] args)         {             Run();         }                 public static void Run()         {             // … Continue reading

Posted in Information Technology | Leave a comment

C# code to figure out missing lines between two text files

static void Main(string[] args)         {             try             {                 int flag = 0;                 StreamReader srt = new StreamReader(@"C:\More.txt");                 for (string str = srt.ReadLine(); str != null; str = srt.ReadLine())                 {                     flag = 0;                     … Continue reading

Posted in Information Technology | Leave a comment

Second largest element of an array

C# code to print the second largest element of an array without using any extra variable: using System; using System.Collections.Generic; using System.Linq; using System.Text;   namespace SecondLargest {     class SecondLargest     {         static void Main(string[] args)         { … Continue reading

Posted in Information Technology | Leave a comment

Swapping array elements

Generic C# code to swap consecutive and then alternate elements in an array. using System; using System.Collections.Generic; using System.Linq; using System.Text;   namespace Swap {     class Swap     {         static void Main(string[] args)         {             int[] array … Continue reading

Posted in Information Technology | Leave a comment