Tuesday, July 3, 2012

Virtual keywords use in C#


Introduction:A virtual keyword is used to modify a method property  event declaration and allow to be overridden in a derived class. in this program the class dimensions contain the two coordinates a,b and the area()virtual method.diffrent shape class such as circle cylinder and sphere inherit the dimensions class and the surface area is calculated for each figure.
Example:using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class TestClass
{
    public class Dimensions
    {
        public const double PI = Math.PI;
        protected double a, b;
        public Dimensions()

        {
        }
         public Dimensions(double a, double b)
        {
            this.a = a;
            this.b = b;
        }

        public virtual double Area()
        {
            return a*b;
        }
    }
    public class Circle : Dimensions
    {
        public Circle(double r)
            : base(r, 0)
        {
        }

        public override double Area()
        {
            return PI * a * b;
        }
    }

    class Sphere : Dimensions
    {
        public Sphere(double r)
            : base(r, 0)
        {
        }

        public override double Area()
        {
            return 100 * PI * a * a;
        }
    }

    class Cylinder : Dimension

    {
        public Cylinder(double r, double h)
            : base(r, h)
        {
        }

        public override double Area()
        {
            return 2 * PI * a * a + 8 * PI * a * b;
        }
    }

    static void Main()
    {
        double r = 10.0, h = 8.0;
        Dimensions c = new Circle(r);
        Dimensions s = new Sphere(r);
        Dimensions l = new Cylinder(r, h);
       
        Console.WriteLine("Area of Circle   = {0:F2}", c.Area());
        Console.WriteLine("Area of Sphere   = {0:F2}", s.Area());
        Console.WriteLine("Area of Cylinder = {0:F2}", 1.Area());
    }
}
Output:
Virtual keywords use in C#

How to Hack Windows Administrator Password

Here is another simple way through which you can reset the password of any non-administrator accounts. The only requirement for this is that you need to have administrator privileges. Here is a step-by-step instruction to accomplish this task.
1. Open the command prompt (Start->Run->type cmd->Enter)
2. Now type net user and hit Enter
3. Now the system will show you a list of user accounts on the computer. Say for example you need to reset the password of the account by name John, then do as follows
4. Type net user John * and hit Enter. Now the system will ask you to enter the new password for the account. That’s it. Now you’ve successfully reset the password for John without knowing his old password.
So in this way you can reset the password of any Windows account at times when you forget it so that you need not re-install your OS for any reason. I hope this helps.

Install windows xp in less than 15 minutes

Install windows xp in less than 15 minutes
  1. Boot through windows xp cd
  2. After all the files are completely loaded,you get the option to select the partition. Select “c:”
  3. Now format the partition,whether it is normal or quick with NTFS or FAT
  4. Once the formatting is completed, All the setup files required for installation are copied. Restart your system by pressing Enter.
  5. Now here begins the simple trick to save 15 minutes.
  6. After rebooting , you get a screen where it takes 40 minutes to complete or finalize OS installation
  7. now press Shift + F10 Key. This opens command Prompt.
  8. Enter “taskmgr” at the command prompt window. This will open task manager
  9. Click the process Tab, here we find a process called Setup.exe . Right click on Setup.exe-> Set priority – > Select High or Above normal. Initially it will be Normal

Wednesday, June 20, 2012

Maximum 255 character textbox counter set

<html>
<head>
  <link rel="canonical" href="http://www.example.com" />
<script language = "Javascript">
/**
 * DHTML textbox character counter script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

maxL=255;
var bName = navigator.appName;
function taLimit(taObj) {
    if (taObj.value.length==maxL) return false;
    return true;
}

function taCount(taObj,Cnt) {
    objCnt=createObject(Cnt);
    objVal=taObj.value;
    if (objVal.length>maxL) objVal=objVal.substring(0,maxL);
    if (objCnt) {
        if(bName == "Netscape"){   
            objCnt.textContent=maxL-objVal.length;}
        else{objCnt.innerText=maxL-objVal.length;}
    }
    return true;
}
function createObject(objId) {
    if (document.getElementById) return document.getElementById(objId);
    else if (document.layers) return eval("document." + objId);
    else if (document.all) return eval("document.all." + objId);
    else return eval("document." + objId);
}
</script>

<body>

<fb:like ref="top_left"></fb:like>
<iframe src="http://www.facebook.com/l.php?fb_ref=top_left&fb_source=profile_oneline"></iframe>







<div id="content">
  <g:plusone size="small"></g:plusone>

    <script type="text/javascript">
      window.___gcfg = {
        lang: 'en-US'
      };

      (function() {
        var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
        po.src = 'https://apis.google.com/js/plusone.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
      })();
    </script>


<font> Maximum Number of characters for this text box is 255.<br>
<textarea onKeyPress="return taLimit(this)" onKeyUp="return taCount(this,'myCounter')" name="Description" rows=7 wrap="physical" cols=40 Maxlength="255">
</textarea>
<br><br>
You have <B><SPAN id=myCounter>255</SPAN></B> characters remaining
for your description...</font>
</body>

</html>


Remove duplicates from a datatable..

using System.Data;

using System.Linq;

DataTable dt = ds.Tables[0];

DataView dv = new DataView(dt);

string cols = string.Empty;

foreach (DataColumn col in dt.Columns)

{

if (!string.IsNullOrEmpty(cols)) cols += ",";

cols += col.ColumnName;

}

dt = dv.ToTable(true, cols.Split(','));

ds.Tables.RemoveAt(0);

ds.Tables.Add(dt);