Sunday, December 29, 2019

angular installation guide

Hi All,

This is an installation guide of angular.
Before creating our first Angular app, first, we’ll see how to install Angular on a Windows system.

Step 1 - Install NodeJS
Follow the link - https://nodejs.org/en/download/
Download the node.js installer for Windows and install it.

To check the installed version of Node.js, open the command prompt.
Type the “npm -v” command to check the Node.js installation and version.

Step 2 - Install TypeScript
Open the link https://www.npmjs.com/package/typescript

Copy the above command “npm install -g typescript” and run it on command prompt.
Step 3 - Install Angular CLI (Angular command line interface)
Open the link https://cli.angular.io/ and follow the instructions to install Angular CLI and to create your first  Angular app.
1)Type the command “npm install -g @angular/cli” on the command prompt and press enter to install Angular cli.
2)Type “ng new hello-world” and hit enter to create the Hello World app.

Thank you,
Arjun Walmiki

Saturday, November 23, 2019

How To Add JavaScript to HTML

Introduction:-

When working with files for the web, JavaScript needs to be loaded and run alongside HTML markup. This can be done either inline within an HTML document or in a separate file that the browser will download alongside the HTML document.
This tutorial will go over how to incorporate JavaScript into your web files, both inline into an HTML document and as a separate file.

Adding JavaScript into an HTML Document

You can add JavaScript code in an HTML document by employing the dedicated HTML tag <script> that wraps around JavaScript code.
The <script> tag can be placed in the <head> section of your HTML, in the <body> section, or after the </body> close tag, depending on when you want the JavaScript to load.
Generally, JavaScript code can go inside of the document <head> section in order to keep them contained and out of the main content of your HTML document.
However, if your script needs to run at a certain point within a page’s layout — like when using document.write to generate content — you should put it at the point where it should be called, usually within the <body> section.
Let’s consider the following blank HTML document with a browser title of Today's Date:
index.html
<!DOCTYPE html>
<html lang="en-US">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Today's Date</title>
</head>

<body>

</body>

</html>
Right now, this file only contains HTML markup. Let’s say we would like to add the following JavaScript code to the document:
let d = new Date();
alert("Today's date is " + d);
This will enable the webpage to display an alert with the current date regardless of when the user loads the site.
In order to achieve this, we will add a <script> tag along with some JavaScript code into the HTML file.
To begin with, we’ll add the JavaScript code between the <head> tags, signalling the browser to run the JavaScript script before loading in the rest of the page. We can add the JavaScript below the <title> tags, for instance, as shown below:
index.html
<!DOCTYPE html>
<html lang="en-US">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Today's Date</title>
    <script>
        let d = new Date();
        alert("Today's date is " + d);
    </script>
</head>

<body>

</body>



</html>
Once you load the page, you will receive an alert that will look similar to this:
JavaScript Alert Example
You can also experiment with putting the script either inside or outside the <body> tags and reload the page. As this is not a robust HTML document, you likely will not notice any difference in the loading of the page.
If we were modifying what is shown in the body of the HTML, we would need to implement that after the <head> section so that it displays on the page, as in the example below:
index.html
<!DOCTYPE html>
<html lang="en-US">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Today's Date</title>
</head>

<body>

  <script>
      let d = new Date();
      document.body.innerHTML = "<h1>Today's date is " + d + "</h1>"
  </script>

</body>

</html>
The output for the above HTML document loaded through a web browser would look similar to the following:
JavaScript Date Example
Scripts that are small or that run only on one page can work fine within an HTML file, but for larger scripts or scripts that will be used on many pages, it is not a very effective solution because including it can become unwieldy or difficult to read and understand. In the next section, we’ll go over how to handle a separate JavaScript file in your HTML document.
We can start with our previous HTML template from the section above:
index.html
<!DOCTYPE html>
<html lang="en-US">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Today's Date</title>
</head>

<body>

</body>

</html>
Now, let’s move our JavaScript code that will show the date as an <h1> header to the script.js file:
script.js
let d = new Date();
document.body.innerHTML = "<h1>Today's date is " + d + "</h1>"
We can add a reference to this script to or below the <body> section, with the following line of code:
<script src="js/script.js"></script>
The <script> tag is pointing to the script.js file in the js/ directory of our web project.
Let’s look at this line in the context of our HTML file, in this case, below the <body> section:
index.html
<!DOCTYPE html>
<html lang="en-US">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Today's Date</title>
</head>

<body>

</body>

<script src="js/script.js"></script>

</html>
Thank you ..............

Wednesday, November 13, 2019

How to pass data from one component to another in angular

In this blog, I am going to explain to you about component communication in angular 2,4,6.

When the parent component wants to communicate child subcomponent or vice-versa so service is a good option. 

@Input
Angular provides us @Input decorator by using that we can pass data from parent component to child component. Let's see an example

child.component.ts

ERROR in The Angular Compiler requires TypeScript.

Hi All,

When you build your application from the command prompt you will get the error in your window.

ERROR in The Angular Compiler requires TypeScript >=2.7.2 and <2.10.0 but 3.5.3 was found instead.

The solution of it as below:- 

You should do npm install typescript@'>=2.7.2 <2.10.0'. This will install the correct typescript your project needs. Make sure you run this inside your Angular project.
On Windows, you should use double quotes instead of single quotes, like so:
npm install typescript@">=2.7.2 <2.10.0"
Otherwise, you'll get the system cannot find the file specified.

Thank you,
Hope it will help you.

Best Regards,
Arjun Walmiki

Keep visiting my blog.

Saturday, September 14, 2019

Hide iframe in angular 6

Hi All,

Today i will show you how to hide the iframe in Angular 6 using *ngif.

photos.component.html :-

the below iframe is inside the into my photos.component.html.

<div id="map_canvas">
        <iframe width="100%" height="380" id="myIframe" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://test/jq-3d-flip-book/"></iframe>
      </div>


I have wrote the below *ngif condition in my photos.component.html.

<div *ngIf="selectedStudent.schoolId == 29; then ifcondition else elsecondition"></div>
<template #ifcondition>
    <iframe id="myIframe" onload="delayedLoad()"></iframe>
</template>
<template #elsecondition>
  <span> Else Condition Works!</span>
</template>


Thank you hope it is help you.

Thank you ,

Arjun Walmiki

OOP question and answer for fresher and experience.

1) What is OOP?
OOP is a design philosophy. It stands for Object Oriented Programming. Object-Oriented Programming (OOP) uses a different set of programming languages than old procedural programming languages (C, Pascal, etc.). Everything inOOP is grouped as self sustainable "objects". Hence, you gain re-usability by means of four main object-oriented programming concepts.
In order to clearly understand the object orientation, let’s take your “hand” as an example. The “hand” is a class. Your body has two objects of type hand, named left hand and right hand. Their main functions are controlled/ managed by a set of electrical signals sent through your shoulders (through an interface). So the shoulder is an interface which your body uses to interact with your hands. The hand is a well architected class. The hand is being re-used to create the left hand and the right hand by slightly changing the properties of it.

2) What is an Object?
An object can be considered a "thing" that can perform a set of related activities. The set of activities that the object performs defines the object's behavior. For example, the hand can grip something or a Student (object) can give the name or address.
In pure OOP terms an object is an instance of a class.

3) What is a Class?


A class is simply a representation of a type of object. It is the blueprint/ plan/ template that describe the details of anobject. A class is the blueprint from which the individual objects are created. Class is composed of three things: a name, attributes, and operations.
  Collapse | Copy Code
public class Student
{
}
According to the sample given below we can say that the Student object, named objectStudent, has been created out of the Student class.
  Collapse | Copy Code
Student objectStudent = new Student();
In real world, you'll often find many individual objects all of the same kind. As an example, there may be thousands of other bicycles in existence, all of the same make and model. Each bicycle has built from the same blueprint. In object-oriented terms, we say that the bicycle is an instance of the class of objects known as bicycles.
In the software world, though you may not have realized it, you have already used classes. For example, the TextBoxcontrol, you always used, is made out of the TextBox class, which defines its appearance and capabilities. Each time you drag a TextBox control, you are actually creating a new instance of the TextBox class.

4) How to identify and design a Class?

This is an art; each designer uses different techniques to identify classes. However according to Object Oriented Design Principles, there are five principles that you must follow when design a class,
SRP - The Single Responsibility Principle -
A class should have one, and only one, reason to change.
OCP - The Open Closed Principle -
You should be able to extend a classes behavior, without modifying it.
LSP - The Liskov Substitution Principle-
Derived classes must be substitutable for their base classes.
DIP - The Dependency Inversion Principle-
Depend on abstractions, not on concretions.
ISP - The Interface Segregation Principle-
Make fine grained interfaces that are client specific.
For more information on design principles, please refer to Object Mentor.
Additionally to identify a class correctly, you need to identify the full list of leaf level functions/ operations of the system (granular level use cases of the system). Then you can proceed to group each function to form classes (classes will group same types of functions/ operations). However a well defined class must be a meaningful grouping of a set of functions and should support the re-usability while increasing expandability/ maintainability of the overall system.
In software world the concept of dividing and conquering is always recommended, if you start analyzing a full system at the start, you will find it harder to manage. So the better approach is to identify the module of the system first and then dig deep in to each module separately to seek out classes.
A software system may consist of many classes. But in any case, when you have many, it needs to be managed. Think of a big organization, with its work force exceeding several thousand employees (let’s take one employee as a one class). In order to manage such a work force, you need to have proper management policies in place. Same technique can be applies to manage classes of your software system as well. In order to manage the classes of a software system, and to reduce the complexity, the system designers use several techniques, which can be grouped under four main concepts named Encapsulation, Abstraction, Inheritance, and Polymorphism. These concepts are the four main gods of OOP world and in software term, they are called four main Object Oriented Programming (OOP) Concepts.

5) What is Encapsulation (or Information Hiding)?

The encapsulation is the inclusion within a program object of all the resources need for the object to function - basically, the methods and the data. In OOP the encapsulation is mainly achieved by creating classes, the classes expose public methods and properties. The class is kind of a container or capsule or a cell, which encapsulate the set of methods, attribute and properties to provide its indented functionalities to other classes. In that sense, encapsulation also allows a class to change its internal implementation without hurting the overall functioning of the system. That idea of encapsulation is to hide how a class does it but to allow requesting what to do.



In order to modularize/ define the functionality of a one class, that class can uses functions/ properties exposed by another class in many different ways. According to Object Oriented Programming there are several techniques, classes can use to link with each other and they are named association, aggregation, and composition.
There are several other ways that an encapsulation can be used, as an example we can take the usage of an interface. The interface can be used to hide the information of an implemented class.
  Collapse | Copy Code
IStudent myStudent = new LocalStudent();
IStudent myStudent = new ForeignStudent();
According to the sample above (let’s assume that LocalStudent and ForeignStudent are implemented by theIStudent interface) we can see how LocalStudent and ForeignStudent are hiding their, localize implementing information through the IStudent interface.

6)  What is Association?

Association is a (*a*) relationship between two classes. It allows one object instance to cause another to perform an action on its behalf. Association is the more general term that define the relationship between two classes, where as the aggregation and composition are relatively special.
  Collapse | Copy Code
public class StudentRegistrar
{
    public StudentRegistrar ();
    {
        new RecordManager().Initialize();
    }
}
In this case we can say that there is an association between StudentRegistrar and RecordManager or there is a directional association from StudentRegistrar to RecordManager or StudentRegistrar use a (*Use*)RecordManager. Since a direction is explicitly specified, in this case the controller class is the StudentRegistrar.


To some beginners, association is a confusing concept. The troubles created not only by the association alone, but with two other OOP concepts, that is association, aggregation and composition. Every one understands association, before aggregation and composition are described. The aggregation or composition cannot be separately understood. If you understand the aggregation alone it will crack the definition given for association, and if you try to understand the composition alone it will always threaten the definition given for aggregation, all three concepts are closely related, hence must study together, by comparing one definition to another. Let’s explore all three and see whether we can understand the differences between these useful concepts.

7) What is the difference between Association, Aggregation, and Composition?

Association is a (*a*) relationship between two classes, where one class use another. But aggregation describes a special type of an association. Aggregation is the (*the*) relationship between two classes. When object of one class has an (*has*) object of another, if second is a part of first (containment relationship) then we called that there is an aggregation between two classes. Unlike association, aggregation always insists a direction.
  Collapse | Copy Code
public class University
{
    private Chancellor  universityChancellor = new Chancellor();
}


In this case I can say that University aggregate Chancellor or University has an (*has-a*) Chancellor. But even without a Chancellor a University can exists. But the Faculties cannot exist without the University, the life time of a Faculty (or Faculties) attached with the life time of the University . If University is disposed theFaculties will not exist. In that case we called that University is composed of Faculties. So that composition can be recognized as a special type of an aggregation.



Same way, as another example, you can say that, there is a composite relationship in-between aKeyValuePairCollection and a KeyValuePair. The two mutually depend on each other.
.NET and Java uses the Composite relation to define their Collections. I have seen Composition is being used in many other ways too. However the more important factor, that most people forget is the life time factor. The life time of the two classes that has bond with a composite relation mutually depend on each other. If you take the .NET Collection to understand this, there you have the Collection element define inside (it is an inner part, hence called it is composed of) the Collection, farcing the Element to get disposed with the Collection. If not, as an example, if you define the Collection and it’s Element to be independent, then the relationship would be more of a type Aggregation, than a Composition. So the point is, if you want to bind two classes with Composite relation, more accurate way is to have a one define inside the other class (making it a protected or private class). This way you are allowing the outer class to fulfill its purpose, while tying the lifetime of the inner class with the outer class.
So in summary, we can say that aggregation is a special kind of an association and composition is a special kind of an aggregation. (Association->Aggregation->Composition)


8) What is Abstraction and Generalization?

Abstraction is an emphasis on the idea, qualities and properties rather than the particulars (a suppression of detail). The importance of abstraction is derived from its ability to hide irrelevant details and from the use of names to reference objects. Abstraction is essential in the construction of programs. It places the emphasis on what an object is or does rather than how it is represented or how it works. Thus, it is the primary means of managing complexity in large programs.
While abstraction reduces complexity by hiding irrelevant detail, generalization reduces complexity by replacing multiple entities which perform similar functions with a single construct. Generalization is the broadening of application to encompass a larger domain of objects of the same or different type. Programming languages provide generalization through variables, parameterization, generics and polymorphism. It places the emphasis on the similarities between objects. Thus, it helps to manage complexity by collecting individuals into groups and providing a representative which can be used to specify any individual of the group.
Abstraction and generalization are often used together. Abstracts are generalized through parameterization to provide greater utility. In parameterization, one or more parts of an entity are replaced with a name which is new to the entity. The name is used as a parameter. When the parameterized abstract is invoked, it is invoked with a binding of the parameter to an argument.

9) What is an Abstract class?

Abstract classes, which declared with the abstract keyword, cannot be instantiated. It can only be used as a super-class for other classes that extend the abstract class. Abstract class is the concept and implementation gets completed when it is being realized by a subclass. In addition to this a class can inherit only from one abstract class (but a class may implement many interfaces) and must override all its abstract methods/ properties and may override virtual methods/ properties.
Abstract classes are ideal when implementing frameworks. As an example, let’s study the abstract class namedLoggerBase below. Please carefully read the comments as it will help you to understand the reasoning behind this code.
  Collapse | Copy Code
public abstract class LoggerBase
{
    /// <summary>
    /// field is private, so it intend to use inside the class only
    /// </summary>
    private log4net.ILog logger = null;

    /// <summary>
    /// protected, so it only visible for inherited class
    /// </summary>
    protected LoggerBase()
    {
        // The private object is created inside the constructor
        logger = log4net.LogManager.GetLogger(this.LogPrefix);
        // The additional initialization is done immediately after
        log4net.Config.DOMConfigurator.Configure();
    }

    /// <summary>
    /// When you define the property as abstract,
    /// it forces the inherited class to override the LogPrefix
    /// So, with the help of this technique the log can be made,
    /// inside the abstract class itself, irrespective of it origin.
    /// If you study carefully you will find a reason for not to have “set” method here.
    /// </summary>
    protected abstract System.Type LogPrefix
    {
        get;
    }

    /// <summary>
    /// Simple log method,
    /// which is only visible for inherited classes
    /// </summary>
    /// <param name="message"></param>
    protected void LogError(string message)
    {
        if (this.logger.IsErrorEnabled)
        {
            this.logger.Error(message);
        }
    }

    /// <summary>
    /// Public properties which exposes to inherited class
    /// and all other classes that have access to inherited class
    /// </summary>
    public bool IsThisLogError
    {
        get
        {
            return this.logger.IsErrorEnabled;
        }
    }
}
The idea of having this class as an abstract is to define a framework for exception logging. This class will allow all subclass to gain access to a common exception logging module and will facilitate to easily replace the logging library. By the time you define the LoggerBase, you wouldn’t have an idea about other modules of the system. But you do have a concept in mind and that is, if a class is going to log an exception, they have to inherit the LoggerBase. In other word the LoggerBase provide a framework for exception logging.
Let’s try to understand each line of the above code.
Like any other class, an abstract class can contain fields, hence I used a private field named logger declare the ILoginterface of the famous log4net library. This will allow the Loggerbase class to control, what to use, for logging, hence, will allow changing the source logger library easily.
The access modifier of the constructor of the LoggerBase is protected. The public constructor has no use when the class is of type abstract. The abstract classes are not allowed to instantiate the class. So I went for the protected constructor.
The abstract property named LogPrefix is an important one. It enforces and guarantees to have a value forLogPrefix (LogPrefix uses to obtain the detail of the source class, which the exception has occurred) for every subclass, before they invoke a method to log an error.
The method named LogError is protected, hence exposed to all subclasses. You are not allowed or rather you cannot make it public, as any class, without inheriting the LoggerBase cannot use it meaningfully.
Let’s find out why the property named IsThisLogError is public. It may be important/ useful for other associated classes of an inherited class to know whether the associated member logs its errors or not.
Apart from these you can also have virtual methods defined in an abstract class. The virtual method may have its default implementation, where a subclass can override it when required.
All and all, the important factor here is that all OOP concepts should be used carefully with reasons, you should be able to logically explain, why you make a property a public or a field a private or a class an abstract. Additionally, when architecting frameworks, the OOP concepts can be used to forcefully guide the system to be developed in the way framework architect’s wanted it to be architected initially.

10) What is an Interface?

In summary the Interface separates the implementation and defines the structure, and this concept is very useful in cases where you need the implementation to be interchangeable. Apart from that an interface is very useful when the implementation changes frequently. Some say you should define all classes in terms of interfaces, but I think recommendation seems a bit extreme.
Interface can be used to define a generic template and then one or more abstract classes to define partial implementations of the interface. Interfaces just specify the method declaration (implicitly public and abstract) and can contain properties (which are also implicitly public and abstract). Interface definition begins with the keyword interface. An interface like that of an abstract class cannot be instantiated.
If a class that implements an interface does not define all the methods of the interface, then it must be declared abstract and the method definitions must be provided by the subclass that extends the abstract class. In addition to this an interfaces can inherit other interfaces.
The sample below will provide an interface for our LoggerBase abstract class.
  Collapse | Copy Code
public interface ILogger
{
    bool IsThisLogError { get; }
}

11) What is the difference between a Class and an Interface?

In .NET/ C#, a class can be defined to implement an interface and also it supports multiple implementations. When aclass implements an interface, an object of such class can be encapsulated inside an interface.
If MyLogger is a class, which implements ILogger, there we can write
  Collapse | Copy Code
ILogger log = new MyLogger();
A class and an interface are two different types (conceptually). Theoretically a class emphasis the idea of encapsulation, while an interface emphasis the idea of abstraction (by suppressing the details of the implementation). The two poses a clear separation from one to another. Therefore it is very difficult or rather impossible to have an effective meaningful comparison between the two, but it is very useful and also meaningful to have a comparison between an interface and an abstract class.

12) What is the difference between an Interface and an Abstract class?

There are quite a big difference between an interface and an abstract class, even though both look similar.
Interface definition begins with a keyword interface so it is of type interface
Abstract classes are declared with the abstract keyword so it is of type class
Interface has no implementation, but they have to be implemented.
Abstract class’s methods can have implementations and they have to be extended.
Interfaces can only have method declaration (implicitly public and abstract) and properties (implicitly public static)
Abstract class’s methods can’t have implementation only when declared abstract.
Interface can inherit more than one interfaces
Abstract class can implement more than one interfaces, but can inherit only one class
Abstract class must override all abstract method and may override virtual methods
Interface can be used when the implementation is changing
Abstract class can be used to provide some default behavior for a base class.
Interface makes implementation interchangeable
Interface increase security by hiding the implementation
Abstract class can be used when implementing framework
Abstract classes are an excellent way to create planned inheritance hierarchies and also to use as non-leaf classes in class hierarchies.
Abstract classes let you define some behaviors; they force your subclasses to provide others. For example, if you have an application framework, an abstract class can be used to provide the default implementation of the services and all mandatory modules such as event logging and message handling etc. This approach allows the developers to develop the application within the guided help provided by the framework.
However, in practice when you come across with some application-specific functionality that only your application can perform, such as startup and shutdown tasks etc. The abstract base class can declare virtual shutdown and startup methods. The base class knows that it needs those methods, but an abstract class lets your class admit that it doesn't know how to perform those actions; it only knows that it must initiate the actions. When it is time to start up, the abstract class can call the startup method. When the base class calls this method, it can execute the method defined by the child class.

13) What are Implicit and Explicit Interface Implementations?

As mentioned before .Net support multiple implementations, the concept of implicit and explicit implementation provide safe way to implement methods of multiple interfaces by hiding, exposing or preserving identities of each of interface methods, even when the method signatures are the same.
Let's consider the interfaces defined below.
  Collapse | Copy Code
interface IDisposable
{
    void Dispose();
}
Here you can see that the class Student has implicitly and explicitly implemented the method named Dispose() viaDispose and IDisposable.Dispose.
  Collapse | Copy Code
class Student : IDisposable
{
    public void Dispose()
    {
        Console.WriteLine("Student.Dispose");
    }

    void IDisposable.Dispose()
    {
        Console.WriteLine("IDisposable.Dispose");
    }
}

14)  What is Inheritance?

The ability of a new class to be created, from an existing class by extending it, is called inheritance.


public class Exception
{
}

public class IOException : Exception
{
}
According to the above example the new class (IOException), which is called the derived class or subclass, inherits the members of an existing class (Exception), which is called the base class or super-class. The class IOExceptioncan extend the functionality of the class Exception by adding new types and methods and by overriding existing ones.
Just like abstraction is closely related with generalization, the inheritance is closely related with specialization. It is important to discuss those two concepts together with generalization to better understand and to reduce the complexity.
One of the most important relationships among objects in the real world is specialization, which can be described as the “is-a” relationship. When we say that a dog is a mammal, we mean that the dog is a specialized kind of mammal. It has all the characteristics of any mammal (it bears live young, nurses with milk, has hair), but it specializes these characteristics to the familiar characteristics of canis domesticus. A cat is also a mammal. As such, we expect it to share certain characteristics with the dog that are generalized in Mammal, but to differ in those characteristics that are specialized in cats.
The specialization and generalization relationships are both reciprocal and hierarchical. Specialization is just the other side of the generalization coin: Mammal generalizes what is common between dogs and cats, and dogs and cats specialize mammals to their own specific subtypes.
Similarly, as an example you can say that both IOException and SecurityException are of type Exception. They have all characteristics and behaviors of an Exception, That mean the IOException is a specialized kind of Exception. A SecurityException is also an Exception. As such, we expect it to share certain characteristic with IOExceptionthat are generalized in Exception, but to differ in those characteristics that are specialized in SecurityExceptions. In other words, Exception generalizes the shared characteristics of both IOException and SecurityException, whileIOException and SecurityException specialize with their characteristics and behaviors.
In OOP, the specialization relationship is implemented using the principle called inheritance. This is the most common and most natural and widely accepted way of implement this relationship.

15) What is Polymorphism?

Polymorphisms is a generic term that means 'many shapes'. More precisely Polymorphisms means the ability to request that the same operations be performed by a wide range of different types of things.
At times, I used to think that understanding Object Oriented Programming concepts have made it difficult since they have grouped under four main concepts, while each concept is closely related with one another. Hence one has to be extremely careful to correctly understand each concept separately, while understanding the way each related with other concepts.
In OOP the polymorphisms is achieved by using many different techniques named method overloading, operator overloading, and method overriding,

15.1) What is Method Overloading?

Method overloading is the ability to define several methods all with the same name.
  Collapse | Copy Code
public class MyLogger
{
    public void LogError(Exception e)
    {
        // Implementation goes here
    }

    public bool LogError(Exception e, string message)
    {
        // Implementation goes here
    }
}

15.2) What is Operator Overloading?

The operator overloading (less commonly known as ad-hoc polymorphisms) is a specific case of polymorphisms in which some or all of operators like +, - or == are treated as polymorphic functions and as such have different behaviors depending on the types of its arguments.
  Collapse | Copy Code
public class Complex
{
    private int real;
    public int Real
    { get { return real; } }

    private int imaginary;
    public int Imaginary
    { get { return imaginary; } }

    public Complex(int real, int imaginary)
    {
        this.real = real;
        this.imaginary = imaginary;
    }

    public static Complex operator +(Complex c1, Complex c2)
    {
        return new Complex(c1.Real + c2.Real, c1.Imaginary + c2.Imaginary);
    }
}
I above example I have overloaded the plus operator for adding two complex numbers. There the two properties named Real and Imaginary has been declared exposing only the required “get” method, while the object’s constructor is demanding for mandatory real and imaginary values with the user defined constructor of the class.

15.3) What is Method Overriding?

Method overriding is a language feature that allows a subclass to override a specific implementation of a method that is already provided by one of its super-classes.
A subclass can give its own definition of methods but need to have the same signature as the method in its super-class. This means that when overriding a method the subclass's method has to have the same name and parameter list as the super-class' overridden method.
  Collapse | Copy Code
using System;
public class Complex
{
    private int real;
    public int Real
    { get { return real; } }

    private int imaginary;
    public int Imaginary
    { get { return imaginary; } }

    public Complex(int real, int imaginary)
    {
        this.real = real;
        this.imaginary = imaginary;
    }

    public static Complex operator +(Complex c1, Complex c2)
    {
        return new Complex(c1.Real + c2.Real, c1.Imaginary + c2.Imaginary);
    }

    public override string ToString()
    {
        return (String.Format("{0} + {1}i", real, imaginary));
    }
}
In above example I have extended the implementation of the sample Complex class given under operator overloading section. This class has one overridden method named ToString, which overrides the default implementation of the standard ToString method to support the correct string conversion of a complex number.
  Collapse | Copy Code
Complex num1 = new Complex(5, 7);
Complex num2 = new Complex(3, 8);

// Add two Complex numbers using the
// overloaded plus operator
Complex sum = num1 + num2;

// Print the numbers and the sum
// using the overriden ToString method
Console.WriteLine("({0}) + ({1}) = {2}", num1, num2, sum);
Console.ReadLine();



Tuesday, August 20, 2019

Abstract class in oop

Abstract class in one of the concept  oop.

So today i will explain you abstract class.

I am using the console application for this example.

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

namespace ConsoleApplication46
{
    /*1. abstract class mean that the class is incomplete and cannot be used directly
    2. abstract class contain abstract method.
    3. you cannot create instance of an abstract class to use its member functions.
    4. Abstract methods are methods without any body.
    5. The implementation of an abstract method is done by the derived class.
     */

    abstract class Animal
    {
        public abstract void Foodhabbits ( );
    }

    class carnivorous:Animal
    {
        /*when a derived class inherits the abstract method from the abstract class,it must override
         the abstract method to provide it a new functionality */

        public override void Foodhabbits ( )
        {
            Console . WriteLine ( "The carnivorous animals eat only meat " );
        }
   }

    class Herbivorous:Animal
    {
        public override void Foodhabbits ( )
        {
            Console . WriteLine ( "Th herbivorous  animals eat only plants " );
        }
   }

    class Program
    {
        static void Main ( string [ ] args )
        {
            carnivorous cn = new carnivorous ( );
            Herbivorous hb = new Herbivorous ( );
            cn . Foodhabbits ( );
            hb . Foodhabbits ( );

            /* in above programe abstract method is inherited in the carnivorous and herbivorous classes.
             abstract method cannot contain any method body*/
        }
    }
}


Thank you,

Hope my example is help you.

Arjun Walmiki

Monday, July 29, 2019

HTTP Error 404. The requested resource is not found.

Dear All,

when you get "HTTP Error 404. The requested resource is not found" error on iis server when deploying.

Ans:- 

How system administrators can troubleshoot an "HTTP 404 - File not found" error message on a server that is running IIS.


when you set project with the domain name and domain name is one of the causes of it.

The solution to it 

1)open cmd on the server. type  "nslookup" and that your domain name.

Problem is resolved.


Thank you,

Hope it helps you in your case.



Regards,
Arjun Walmiki

Wednesday, July 24, 2019

Get the selected value in a dropdown using jQuery.

Dear All,


I am posting this blog because most of the people are stuck in code when we want data from dropdown. So I decided to post this blog.

so this is my dropdown:- 

 <select required="" name="AssignedTo" id="LanguageToInvo" onchange="" class="form-control">
                                            <option id="0" value="">--select---</option>
                                            <option id="1" value="En">English</option>
                                            <option id="2" value="Ar">Arabic</option>
                                            <option id="3" value="EnAr">English and Arabic</option>
                                        </select>


How to get selected value or text from the same. Using Jquery we can get it easily.


If you want value:-


jQuery("#availability option:selected").val();

$("#availability option:selected").val();


If you want to text :-

jQuery("#availability option:selected").text();

$("#availability option:selected").text();


Thank you,

Hope it helps you.

Best regards,
Arjun walmiki





How to call Partial view inside a view in Asp.net Code

Dear All,

This post is useful to the beginner.

Today I will tell you how to call Partial view inside a view. This partial view will be work in MVC or  Asp.net core application.

This is syntax you have to write inside a view:-

@Html.Partial("ParentInvitationArabic.cshtml")



Thank you,
Arjun Walmiki

Monday, June 24, 2019

Web Application Project Option in Visual Studio 2005 Tutorial 1

Hi All ,

Today i will show you how ti create web project in visual studio 2005.

Tutorial 1:

The Visual Studio 2005 Web Application Project Model is a new web project option for Visual Studio 2005 that provides the same conceptual web project approach as VS 2003 (a project file based structure where all code in the project is compiled into a single assembly) but with all the new features of VS 2005 (refactoring, class diagrams, test development, generics, etc) and ASP.NET 2.0 (master pages, data controls, membership/login, role management, Web Parts, personalization, site navigation, themes, etc).

Tutorial 1: Building Your First Web Application Project

The below tutorial walks-through how to create, build and run your first web app using C# and the ASP.NET Web Application Project support in VS 2005.

Creating a New Project

Select File->New Project within the Visual Studio 2005 IDE. This will bring up the New Project dialog. Click on the “Visual C#” node in the tree-view on the left hand side of the dialog box and choose the "ASP.NET Web Application" icon:

Choose where you want the project to be created on disk (note that there is no longer a requirement for web projects to be created underneath the inetpub\wwwroot directory -- so you can store the project anywhere on your filesystem). Then name it and hit ok.

Visual Studio will then create and open a new web project within the solution explorer. By default it will have a single page (Default.aspx), an AssemblyInfo.cs file, as well as a web.config file. All project file-meta-data is stored within a MSBuild based project file.




Opening and Editing the Page


Double click on the Default.aspx page in the solution explorer to open and edit the page. You can do this using either the HTML source editor or the design-view. Add a "Hello world" header to the page, along with a calendar server control and a label control (we'll use these in a later tutorial):

Build and Run the Project

Hit F5 to build and run the project in debug mode. By default, ASP.NET Web Application projects are configured to use the built-in VS web-server (aka Cassini) when run. The default project templates will run on a random port as a root site (for example: http://localhost:12345/):
You can end the debug session by closing the browser window, or by choosing the Debug->Stop Debugging (Shift-F5) menu item.

Looking under the covers

When you compile/build ASP.NET Web Application projects, all code-behind code, embedded resources, and standalone class files are compiled into a single assembly that is built in the \bin sub-directory underneath the project root (note: you can optionally change the location if you want to - for example, to build it into a parent application directory).
If you choose the "Show All Files" button in the solution explorer, you can see what the result of our compilation output looks like:
This works exactly the same as with Visual Studio 2003 ASP.NET Web Application Projects

Customizing Project Properties

ASP.NET Web Application Projects share the same configuration settings and behaviors as standard VS 2005 class library projects. You access these configuration settings by right-clicking on the project node within the Solution Explorer in VS 2005 and selecting the "Properties" context-menu item. This will then bring up the project properties configuration editor. You can use this to change the name of the generated assembly, the build compilation settings of the project, its references, its resource string values, code-signing settings, etc:
ASP.NET Web Application Projects also add a new tab called "Web" to the project properties list. Developers use this tab to configure how a web project is run and debugged. By default, ASP.NET Web Application Projects are configured to launch and run using the built-in VS Web Server (aka Cassini) on a random HTTP port on the machine.
This port number can be changed if this port is already in use, or if you want to specifically test and run using a different number:
Alternatively, Visual Studio can connect and debug IIS when running the web application. To use IIS instead, select the "Use IIS Web Server" option and enter the url of the application to launch, connect-to, and use when F5 or Control-F5 is selected:
Then configure the url to this application in the above property page for the web project. When you hit F5 in the project, Visual Studio will then launch a browser to that web application and automatically attach a debugger to the web-server process to enable you to debug it.
Note that ASP.NET Web Application Projects can also create the IIS vroot and configure the application for you. To do this click the "Create Virtual Directory" button.
Click here to go to the next tutorial.