Pages

Sunday, 10 September 2017

No Investment..!! Awesome way to generate money using Digital Marketing. Just Click on Find the Best Rate Button





For more info email me on pranilkadam47@gmail.com

Sunday, 25 December 2016

1.What is abstract class?

-A abstract class is similar to the class which contains abstract as well as Non abstract method (Normal or concrete Method).

2. What is Abstract Method and Non Abstract Method(Concrete Method)?


Abstract Method- A method which does not have definition and contains abstract keyword before return type ( Here return type is void)

-Example of Abstract method- public abstract void print();

Non-Abstract Method- A method which have definition.

-Example of Non Abstract Method- public void print()

{

}

3. Rules for Writing Abstract Class and Abstract Method-

Abstract method does not definition.
Abstract method contains in abstract class.
It is mandatory to write definition of abstract method in derived class.
Use "override" keyword for writing abstract method definition.
For e.g. public override void print() { }


4. When to use Abstract Class?

-When we want to move the common functionality of 2 or more related classes into a base class and when we don't want that base class to be instantiated.

For Example:

Consider Example of Employee, Name is common property for all Employee. so we can write it in abstract class. But there are some Full Time and Part Time Employees. so their salary is calculated differently. that is why we can write two methods as abstract and their implementation in separate classes.

abstract class Employee
{
//Normal Method or concrete Method
public void Name(int name)
{
Console.WriteLine("Name of Employee :"+name);
}
//Abstract Methods
public abstract void FullTime();
public abstract void PartTime();
}

class FullTimeEmployee : Employee
{
public override void FullTime()
{
Console.WriteLine("Full Time Employee Salary ::");
}
}
class PartTimeEmployee : Employee
{

public override void PartTime()
{
Console.WriteLine("Part Time Employee Salary ::");
}
}

5. How to write Abstract Class and Abstract Method?

If you write Non-abstract method without definition like this public void Print();

You will get error like Error - 'Employee.Print()' must declare a body because it is not marked abstract,extern or partial.

If you write abstract method in Non Abstract class
(class without abstract keyword)
class Employee
{
//Normal Method or concrete Method
public void Name(int name)
{
Console.WriteLine("Name of Employee :" + name);
}

//Abstract Method
public abstract void Print();
}

then you will get error like this -

Error - Employee.Print()' is abstract but it is contained in non-abstract class 'Employee' .

It is mandatory to have implementation of abstract method in derived class otherwise you will get following error
Error - FullTimeEmployee' does not implement inherited abstract member .Employee.FullTime()'

I have written public abstract void FullTime(); abstract method in Employee class and Employee class is inherited in FullTimeEmployee. I have commented the definition of definition of FullTime() Method.

abstract class Employee
{
//Normal Method or concrete Method
public void Name(int name)
{
Console.WriteLine("Name of Employee :" + name);
}
//Abstract Methods
public abstract void FullTime();

}

class FullTimeEmployee : Employee
{
//public override void FullTime()
//{
// Console.WriteLine("Full Time Employee Salary ::");
//}

}

We can not create instance of the Abstract Class.
If You try to create Instance of the abstract class then you will get following error

Error - Cannot create an instance of the abstract class or interface 'Employee'

In out Example Employee is the abstract class.

class Program
{

static void Main(string[] args)
{
Employee objEmp = new Employee();
}

}

Abstract class can be used as a base class.
Abstract class can't be sealed type.
(Sealed type means we can derive new class from sealed class.)
Example of Abstract Class with Sealed Keyword-

abstract sealed class Employee
{
//Normal Method or concrete Method
public void Name(int name)
{
Console.WriteLine("Name of Employee :" + name);
}
//Abstract Method
public abstract void FullTime();
}

Error in above Example - Employee': an abstract class cannot be sealed or static.

We can write property inside abstract class.
We can declare default and parameterized constructor inside abstract class.

Sunday, 12 June 2016

Build vs Rebuild vs Clean in .Net

What is difference between Build vs Rebuild vs Clean in .net??


Build solution- if your code file has changed then it will build them.
If your code file has not changed then it won't build.

Rebuild solution- it will build all code files irrespective they are changed or not.

Clean solution- Delete code files.


Rebuild =Clean + Build

then What is difference between rebuild and clean + build solution??

If you have solution which contains two projects say p1 and p2.
if you perform Rebuild then first it will clean project p1 then it will build project p1.
after that project p2 will be clean then it will build project p2.

if you perform clean + Build then first it will clean project p1 and p2 then it will build project p1 and p2 respectivly.

Please comment if you like this post and you can give also suggestion.

Friday, 10 June 2016

Unobtrusive Javascript

What is unobtrusive javascript?


When we talk about web application there are two things, one is Presentation and other one is Behaviour.
Presentation is done by HTML and behaviour is implemented using Javascript.

Now take simple example and understand scenario

To create simple textbox we will write following HTML code
/*code*/
(opening angle bracket) input id="btn1" type="Button" value="Click to Run Javascript" (closing angle bracket)

output of above code:


above code will generate simple button.

Now i want to add behaviour to button. behaviour means i want to show alert box when i click on the button.

Following is the code for above scenario:

Here i have added onclick event to button.

output of above code:



If you want to change the behaviour (for e.g onchange event instead of onclick) then you need to modify your presentation code i.e HTML code. so i can separate this presentation and behaviour and make HTML code more clean.

Unobtrusive javascript separates the presentation from the behaviour.


Step 1: Create separate javascript file (myscript.js) and write down following code into myscript.js



Step 2: refer this js file onto your HTML page and final code looks like
Here we have moved onclick event to separate file called myscript.js so our HTML code is now clean and simple.

Output of above code:



If you like this post then please comment and you can also give suggestion to improve this.

Thursday, 9 June 2016

What is need of document.ready() in JQuery?


Here to illustrate the need of document.ready().
we will write jQuery code without document.ready() before the textbox code and let's run.
so we will get output but textbox is empty.


Output of above code:



Why we get empty textbox?
DOm means Document Object Model
It is in-memory representation of your HTML.It is loaded by browser in interpreted manner. Interpreted manner means line by line execution from top to bottom.so in our case script is getting executed before the textbox element code. so textbox is not loaded into memory while executing script that's why we are getting empty textbox.

Then what is the solution for above problem??

answer is use document.ready()

document.ready() means when the final line of HTML is read then DOM is loaded after that fired this action.

Following example shows need of document.ready():

Output of above code:

What is JQuery? and What is difference between javascript and jQuery?

What is JQuery? and What is difference between javascript and jQuery?




Jquery is a resuable javascript library.
JQuery is not mean to replace javascript.JQuery has derived from Javascript. Javascript is a language.

Let's take simple example to understand How JQuery simplifies code.
Following code shows How to display simple text into textbox using Javascript.


Output of above code:


Now take same example and implement it using jQuery

we required to download jQuery file first.
you can donwload Jquery file from this URL.
jQuery File

Jquery syntax starts with $ sign, after that element name like textbox and then action which we want to perform. In our example action is val.

Following code shows How to display simple text into textbox using JQuery.



Output of above code:





Tuesday, 5 April 2016

CSS : Difference Between Class and Id

What is ID and Class in CSS?

ID and Class are the selectors in the CSS.

When to Use ID and Class selector?

When we want to select specific element on the page. you can select through ID and Class name.

Similarity Between ID and Class Selector::

ID and Class selector can be used on multiple elements at the same time.

Sample Program of ID selector:
Output of ID selector:



Sample Program of Class selector:
Output of Class selector:




Differences between ID and Class Selector::
1)ID's are unique
2)Each element can have only one ID.
3)If You specify multiple ID's for single element then it won't execute. see the below example.

Sample Program of Multiple ID selector:
Output of Multiple ID selector:


4)Each element can have Multiple class selectors.
5)Class selectors are not unique.
5)If You specify multiple Class for single element then it will execute properly.
Sample Program of Multiple Class selector:
Output of Multiple Class selector: