Pages

Saturday, October 29, 2011

Configure Eclipse for Android Dev/Tools not found Error

Just started up with my first development with Android here is the link to how to setup Android ADT Package in Eclipse...
 
http://developer.android.com/sdk/eclipse-adt.html#installing
 
Here is the link for complete guide.
 
http://developer.android.com/sdk/installing.html#Installing
 
And if you are still getting an error like tools not found in android sdk in Eclipse
  
Run Android SDK Manager from start menu 
 
On the top you will see SDK Path

copy that path(you won't be able to copy it practically.I meant just take a note of that path)

run eclipse 
 
it will show an error that tools not found in a given directory

click on window menu select preferences

select Android from the list on left hand side 
 
on the right hand side you will find "SDK Location". Copy that path next to that and Bingo issue resolved 

Tuesday, October 18, 2011

Storage Types in C Sharp

C Sharp has following types to Manage Data 1. Value 2. Reference 3. Pointer 4. Void Value types are used to store data.Two types are Struct and Enumeration Struct types include structures and built in simple types(int,float) Enumeration is a user type defined variables or we can say set of named constants Reference types are used to store references to data elsewhere in your c# program.Reference type keywords include Class,Interface,Delegate,Object,String Pointer types let you point to specific location in memory Use Void type in a method to specify that method does not returns a value...

Difference between Structure a class and its use.

The basic difference between a structure and a class is that a class is a reference type while a structure is not.All the information regarding different properties and functionality of an of an object are contained in the structure it self. Though Classes have an edge over structures as they belong to the Oops family structures are much handy in cases where there are limited range of values for a particular entity For example color of car and its model....etc...Structures are handy where we require less space comparatively Structures can include constructors but these must include parameters Structures cannot inherit another structure but they can implement interfaces.... Classes use Heap method for storage to which further space can be allocated easily while Structures use stacks as a storage medium so their storage is not expandable that is why where memory constraint is a factor structures and Unions are preferred over classes

Tuesday, September 27, 2011

Usage of Obsolete attribute

Recently I came across a fine technique to mark your old code as obsolete in C#. I did some research work and Book called the same as an Insert attribute.Leaving the theory apart the practical was was that interested me the most and here I present an example of the same.

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

namespace Types
{
class Program
{
enum weekdays {mon=1,tue,wed,thurs,fri,sat,sun}

//Use of obsolete attribute to mark a function a obsolete
[Obsolete("Use newmethod", true)]
static void oldmethod()
{
Console.WriteLine("No");
}

static void newmethod()
{
Console.WriteLine("Yes");
}

public static void Main(string[] args)
{
int x = (int)weekdays.wed;
Console.WriteLine("The wednesday Enum value is {0}",x);
newmethod();
}
}
}

now when I call "oldmethod()" It gives an error with a message specified as in the code...

and on calling "newmethod()" it runs fine

I peeped more into their family and found following attributes also as a part which I will discuss later

AttributeUsage
AttributeTargets
Conditional
Obsolete as discussed in this post...

Boxing and Unboxing in OOPS

Boxing is a process of conversion of a value to generic object type for example

Consider the following code

Int alpha=1;
object boxed_alpha= alpha;

This conversion to generic type is called as boxing

Unboxing is the reverse of a boxing continuing with the above example let us unbox boxed_alpha as a string

String string_alpha=(String) boxed_alpha;

OR

String string_alpha=boxed_alpha.ToString();

I will discuss its use subsequent comments

Thursday, September 15, 2011

Getting the address of last visited page

The "document.referrer" is a string object that holds a web address of the document from which the current HTML document was reached

The Link Object of Document in javascript

In java script the link object as following properties

1) Link.hash->contains the hash portion of the web address
2) Link.host->contains host information from the links web address
3) Link.href->contains entire web address specified in the link
4) Link.hostname->contains information regarding hostname from links web address
5) Link.pathname->contains path to the file link is directed to
6) Link.port->contains the port specified in web address
7) Link.protocol->protocol specified in link's web address
8) Link.search->Querystring specified in the web address
9) Link.target->object containing name of target window
10)Link.innerHtml->Text that shows up for the link