Wednesday, May 16, 2012

Compare Two Arrays in C#


using System;

namespace CompareTwoArrays
{
    class Program
    {
        static void Main(string[] args)
        {
            String[] arrayItem1 = {
                                    "dog",
                                    "cat",
                                    "wolf",
                                    "orange"
                                  };
            String[] arrayItem2 = {
                                    "fox",
                                    "wolf",
                                    "bear",
                                    "dog",
                                    "banana",
                                    "paper",
                                    "cat"
                                  };
            Boolean isMatch = false;
            foreach (String itemArray1 in arrayItem1)
            {
                foreach (String itemArray2 in arrayItem2)
                {
                    if (String.Compare(itemArray1,itemArray2,true)==0)
                    {
                        isMatch = true;
                        Console.WriteLine("Array element {0} in arrayItem1 was found in arrayItem2", itemArray1);
                    }
                }
                if (!isMatch)
                {
                    Console.WriteLine("Array element {0} in arrayItem1 was not found in arrayItem2", itemArray1);
                }
                isMatch = false;
            }
            Console.Read();
        }
    }
}

********************************************************************************



Tuesday, May 15, 2012

Browser Capabilities in Asp.Net


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default1.aspx.cs" Inherits="Default1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Browser Capabilities in Asp.Net</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
    </div>
    </form>
</body>
</html>


*************************************************************************************

using System;

public partial class _Default1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
System.Web.HttpBrowserCapabilities browserCapabilities = Request.Browser;
string s = "

Browser Capabilities


"
+
"Type = " + browserCapabilities.Type + "
"
+
"Name = " + browserCapabilities.Browser + "
"
+
"Version = " + browserCapabilities.Version + "
"
+
"Major Version = " + browserCapabilities.MajorVersion + "
"
+
"Minor Version = " + browserCapabilities.MinorVersion + "
"
+
"Platform = " + browserCapabilities.Platform + "
"
+
"Is Beta = " + browserCapabilities.Beta + "
"
+
"Is Crawler = " + browserCapabilities.Crawler + "
"
+
"Is AOL = " + browserCapabilities.AOL + "
"
+
"Is Win16 = " + browserCapabilities.Win16 + "
"
+
"Is Win32 = " + browserCapabilities.Win32 + "
"
+
"Supports Frames = " + browserCapabilities.Frames + "
"
+
"Supports Tables = " + browserCapabilities.Tables + "
"
+
"Supports Cookies = " + browserCapabilities.Cookies + "
"
+
"Supports VBScript = " + browserCapabilities.VBScript + "
"
+
"Supports JavaScript = " +
browserCapabilities.EcmaScriptVersion.ToString()
+ "
"
+
"Supports Java Applets = " + browserCapabilities.JavaApplets + "
"
+
"Supports ActiveX Controls = "
+ browserCapabilities.ActiveXControls
+
"
";
Response.Write(s);

}
}

*************************************************************************************