Friday 4 June 2021

Paul_testing.aspx

 [Paul_testing.aspx] page: This is page for testing the code before implement in the main page:

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class paul_testing : System.Web.UI.Page
{
    public static byte[] bytes;
    protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
        try
        {
            SqlCommand cmd = new SqlCommand("SELECT * FROM id_pwd", con);
            con.Open();
            SqlDataReader dr = cmd.ExecuteReader();

            if (dr.Read())
            {
                GridView1.DataSource = dr;
                GridView1.DataBind();

                txt_test.Text = dr[1].ToString();
                
            }
            else
            {
                GridView1.DataSource = null;
                GridView1.DataBind();
                txt_test.Text = dr[1].ToString();
            }
        }
        catch (Exception ex)
        {
            Response.Write("Error Occured: " + ex.ToString());
        }
        finally
        {
            con.Close();
        }

        //Testing Application State
        //if two clients requested the page at the same time. Then deadlock will occur.
        //We can avoid deadlock occurrence while we updating application variable
        //by multiple users with help of Lock() and UnLock().

        Application.Lock();
        int count = 0;
        if (Application["app_state"] != "")
        {
            count = Convert.ToInt32(Application["app_state"]);
        }
        count = count + 1;
        Application["app_state"] = count;

        Application.UnLock();
        lbl_app_state.Text = "Total Visited People Are:" + "  " + Convert.ToString(count);

        //Testing Application State



        //string dt = "6/28/2019 12:00:00    AM";

        //string[] st1 = dt.Split(' ');
        //dt = st1[0];
        //string dt2 = dt;
        //string[] st2 = dt2.Split('/');

        //string d = st2[1];
        //string m = st2[0];
        //string y = st2[2];
        //string add = d+ "/" + m+ "/" + y;




        ////SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
        ////con.Open();
        ////SqlDataAdapter da = new SqlDataAdapter("select * from frs_status_regulatory_rl where frs_no='A-216/18-19' and order_no='D-182/18-19a' and pro_code='24000' ", con);
        //SqlDataAdapter da = new SqlDataAdapter("select * from [reactor_process] where reactor_no='R-09' and r_status='Waiting' and plant='RL-HP' and  block='Block-1' and start_dt='12/30/2018 6:00:00 AM' and stop_dt='12/31/2018 6:00:00 AM' ", con);




        ////SqlDataAdapter da = new SqlDataAdapter("SELECT DISTINCT cust.frs_no AS FRS_NO, cust.order_no AS Order_No, cust.pro_code AS Product_Code, cust.date AS Date, contact.qty AS Quantity,contact.packaging as Packaging, contact.spec AS Specification, contact.o_spec AS Other_Specification, contact.mkt_remarks AS Mkt_Remarks, cust.pro_remarks AS Prod_Remarks, cust.pro_approve AS Prod_Approve, cust.qc_remarks AS QC_Remarks, cust.qc_approve AS QC_Approve, contact.party_code,contact.additional_info,contact.type_of_drum FROM frs_status_regulatory_rc AS cust INNER JOIN frs_regulatory_rc AS contact ON cust.order_no = contact.order_no AND cust.frs_no = contact.frs_no WHERE (cust.date <> '') AND (cust.qc_date IS NULL) AND (cust.back IS NULL) ORDER BY FRS_NO, Order_No ", con);




        


        ////string sys1 = "ujjwal";
        ////Session["ujjwal"] = sys1;
        ////lbl_sys1.Text = Session["ujjwal"].ToString();


    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            ////SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
            ////con.Open();
            ////SqlCommand cmd11 = new SqlCommand("delete from [reactor_process] where reactor_no='R-09' and r_status='Waiting' and plant='RL-HP' and  block='Block-1' and start_dt='12/30/2018 6:00:00 AM' and stop_dt='12/31/2018 6:00:00 AM'", con);
            ////cmd11.ExecuteNonQuery();


            ////SqlCommand cmd31 = new SqlCommand("insert into [i_mark_rc] ([order_no],[o_rcv_date],[buyer_name],[agent_name],[o_placing_date],[c_order_no],[destination],[region],[pro_name],[pro_code],[specification],[other_specification],[qty],[price],[packaging],[delivery_date],[commission],[date_m],[o_no],[con_name],[order_type],[party_code],[adc_sample]) values ('" + Label34.Text + "','" + Label33.Text + "','" + DropDownList5.Text + "','" + DropDownList6.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + DropDownList33.Text + "','" + DropDownList7.Text + "','" + DropDownList12.Text + "','" + DropDownList17.Text + "','" + TextBox5.Text + "','" + TextBox10.Text + "','" + TextBox15.Text + "','" + TextBox20.Text + "','" + TextBox25.Text + "','" + TextBox30.Text + "','" + TextBox50.Text + "','" + Label47.Text + "','" + DropDownList22.Text + "','" + DropDownList23.Text + "','" + DropDownList28.Text + "','" + DropDownList34.Text + "')", con);
            //cmd31.ExecuteNonQuery();
            // con.Close();
        }
        catch (Exception ex)
        {
            string str = ex.Message;
        }



    }

    protected void btn_demo_Click(object sender, EventArgs e)
    {
        //try
        //{
        //    string startdate = "10/26/2017 12:00:00 AM";
        //    string enddate = "10/31/2017 12:00:00 AM";
        //    string s3 = "";
        //    string s4 = "";
        //    //SELECT distinct convert(varchar(11), date1, 106) ColName FROM [reactor_process] where start_dt > startdate and start_dt <= enddate and block = 'P1'

        //    SqlDataAdapter da = new SqlDataAdapter("select reactor_no, pro_name, pro_stage, batch_no, r_status, plant, block, start_dt, stop_dt, ROUND(CAST(DATEDIFF(minute, start_dt, stop_dt) / 60.00 AS float), 2) AS Occupancy, remarks from [reactor_process] where (start_dt BETWEEN '" + a + "' AND '" + b + "') AND (stop_dt BETWEEN '" + a + "' AND '" + b + "') AND plant = '" + DropDownList1.SelectedItem + "'AND block = '" + DropDownList3.SelectedItem + "' order by CAST(SUBSTRING(reactor_no, CHARINDEX('R', reactor_no)+1,99) AS SMALLINT)", con111);
        //    DataTable dt = new DataTable();
        //    da.Fill(dt);
        //    txt_test.Text = dt.Rows[0][""].ToString();
        //}
        //catch(Exception ex)
        //{
        //    string str = ex.Message;
        //}
    }

    protected void btn_submitt_ipc_Click(object sender, EventArgs e)
    {
        //try
        //{

        //        string filename = Path.GetFileName(FileUpload1.PostedFile.FileName);
        //        string contentType = FileUpload1.PostedFile.ContentType;
        //        string lock1 = "lock";

        //        using (Stream fs = FileUpload1.PostedFile.InputStream)
        //        {
        //            using (BinaryReader br = new BinaryReader(fs))
        //            {
        //                bytes = br.ReadBytes((Int32)fs.Length);
        //                drp_invoice_no_ipc.Text = "2";
        //                SqlConnection cn1 = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
        //                cn1.Open();
        //                SqlCommand cmd1 = new SqlCommand("insert into [post_logistic_export_rl] (invoice_no, appname_ipc, Attachment_ipc, ContentType_ipc, ipc_lock) values (@invoice_no, @appname_ipc, @Attachment_ipc, @ContentType_ipc, @ipc_lock)", cn1);
        //                cmd1.Parameters.AddWithValue("@invoice_no", drp_invoice_no_ipc.Text);
        //                cmd1.Parameters.AddWithValue("@appname_ipc", filename);
        //                cmd1.Parameters.AddWithValue("@Attachment_ipc", contentType);
        //                cmd1.Parameters.AddWithValue("@ContentType_ipc", bytes);
        //                cmd1.Parameters.AddWithValue("@ipc_lock", lock1);
        //                cmd1.ExecuteNonQuery();


        //                cn1.Close();
        //            }
        //        }               
        //        ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert(' Successfully Inserted ');window.location.replace('log_post_ipc_ab_export_rl.aspx');", true);
        //    }

        //catch (Exception ex)
        //{
        //    string str = ex.Message;
        //}
    }

    protected void btn_update_Click(object sender, EventArgs e)

    {
        try
        {
            string extension1 = Path.GetExtension(FileUpload1.FileName);
            string p1 = Path.GetFileName(FileUpload1.PostedFile.FileName);// p1_name(pdf file name fetch)
            string filename1 = Path.GetFileName(FileUpload1.PostedFile.FileName);
            string contentType1 = FileUpload1.PostedFile.ContentType;
            string[] s1 = p1.Split('.');
            p1 = s1[0];
            SqlConnection cn1 = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
            cn1.Open();
            using (Stream fs = FileUpload1.PostedFile.InputStream)
            {
                using (BinaryReader br = new BinaryReader(fs))
                {
                    byte[] bytes = br.ReadBytes((Int32)fs.Length);
                    string strQuery = "Update d_pending_rl Set ContentType = @profilepic,appname=@appname Where order_no = 'D-1022/19-20a'";
                    SqlCommand cmd = new SqlCommand(strQuery, cn1);
                    cmd.Parameters.AddWithValue("@profilepic", bytes);
                    cmd.Parameters.AddWithValue("@appname", filename1);
                    //cmd.Parameters.AddWithValue("@p1_name", p1);
                    //  InsertUpdateData(cmd);
                    cmd.ExecuteNonQuery();
                }

            }
            cn1.Close();
        }
        catch (Exception ex)
        {
            string str = ex.Message;
        }
    }
}

FAQ--(ADO .Net)

BACK

 FAQ Lists:

1) ExecuteReader , ExecuteNonQuery, ExecuteScalar.

2) (DataAdapter--DataSet) and  (DataReader).

3) (DataTable) and (DataSet).

 

 

 1. A) DataAdapter:  Use


 protected void btn_adapter_Click(object sender, EventArgs e)
    {
        //Observation: SQL Data Adapter
        //1. Opne and Close of connection not required.

        SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);

        //SqlDataAdapter adp = new SqlDataAdapter("select * from i_ce_rl order by invoice_no", con);
        SqlDataAdapter adp = new SqlDataAdapter("SELECT name,marks FROM test1 where marks = (select min(marks) from test1) ", con);

        DataTable dt = new DataTable();
        adp.Fill(dt);

        ////Session["SID"] = dt;
        ////DataTable dttt = (DataTable)Session["SID"];  // It is possible
        ////lbl_inv1.Text = (dt.Rows[0]["date"]).ToString(); // Not required con.Open(); and con.close();

        gv1.DataSource = dt;
        gv1.DataBind();
    }

_______

1.B) Command cmd Use :

 protected void btn_cmd_Click(object sender, EventArgs e)
    {
        //Observation: SqlCommand
        //1. Opne and Close connection needs. Mandatory

        SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);

        con.Open();
        SqlCommand cmd = new SqlCommand("select * from i_ce_rl order by invoice_no", con);
        SqlDataReader dr = cmd.ExecuteReader();
        DataTable dt = new DataTable();

        if(dr.Read())
        {
            lbl_inv2.Text = dr["date"].ToString();
        }
        gv2.DataSource = dr;
        gv2.DataBind();

        con.Close();
    } 

 

1.C) Command cmd and DataAdapter Both Use :

protected void btn_cmd_adp_Click(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);

        SqlCommand cmd = new SqlCommand("select * from i_ce_rl order by invoice_no", con);
        SqlDataAdapter adp = new SqlDataAdapter(cmd);
        DataTable dt = new DataTable();

        adp.Fill(dt);
        gv3.DataSource = dt;
        gv3.DataBind();

        //Now By using SqlDataAdapter assign the date column to the Label
        lbl_inv3.Text = Convert.ToString(dt.Rows[0]["date"]);

        //Now By using SqlDataReader assign the date column to the Label. Connection Open and Close required.
        con.Open();
        SqlDataReader dr = cmd.ExecuteReader();
        if(dr.Read())
        {
            lbl_inv4.Text = dr["date"].ToString();
        }
        con.Close();

    }

 

2. DataTable And DataSet Use:

protected void btn_dt_ds_Click(object sender, EventArgs e)
    {
        //Observation : (DataTable And DataSet )
        //1. DataTable can work with one table only But DataSet can work with multiple Tables, it is a collection of Tables of DB.
        //2. DataTable fetches only one TableRow at a time whereas DataSet can fetch multiple TableRows at a time.
        //3. In DataTable,  DataSource cannot be  serialized. But DataSet is serialized DataSource .That is why web services can always returns DataSet as the result but not the DataTables.
        //4. Dataset is a collection of tables, which is used in disconnected architecture. Generally to fill DataSet we use fill method of SqlDataAdapter. It can be used for manipulating the data remotely and finally updating the database with the modified data.
        // whereas DataTable is the collection of rows and columns in a table, which used in Connection architecture always needs a con.Open() and con.Close(); to communicates with the DataSource(DB).



        SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);

        SqlDataAdapter adp = new SqlDataAdapter("select * from i_ce_rl order by invoice_no", con);
        //using DataTable Below:
        DataTable dt = new DataTable();
        adp.Fill(dt);
        gv4.DataSource = dt;
        gv4.DataBind();

        //using DataSet Below:
        //DataSet ds = new DataSet();
        //adp.Fill(ds);
        //gv4.DataSource = ds.Tables[0];
        //gv4.DataBind();
    }

 

HOME BACK

FAQ-- SQL(Query Only)

BACK

1.Query :get minimum salary along with name.
         Main Table: [test1]
    Name Marks
        A   50
        B   40
        C   30
        D   20
        E   20

        Output:
        name marks
        D   20
        E   20
        SqlDataAdapter adp = new SqlDataAdapter("SELECT name,marks FROM test1 where marks = (select min(marks) from test1) ", con);

        2. Query: Sum of the marks.output=160
        SqlDataAdapter adp = new SqlDataAdapter("select sum(marks) as SUM from test1 ", con);

        3. Query: Highest marks from table test1.output=50
        SqlDataAdapter adp = new SqlDataAdapter("select MAX(marks) from test1 ", con);

        4.Query: 2nd Highest marks from table test1.output=40
        SqlDataAdapter adp = new SqlDataAdapter("select MAX(marks) from test1 where marks <(select MAX(marks) from test1) ", con);
    Query: 3rd Highest marks from table test1.output=30
        SqlDataAdapter adp = new SqlDataAdapter("select MAX(marks) from test1 where marks <( select MAX(marks) from test1 where marks<(select MAX(marks) from test1) ) ", con);
    SqlDataAdapter adp = new SqlDataAdapter("select marks from test1 as t1 where 3=(select count(*) from test1 as t2 where t1.marks<=t2.marks) ", con);


        5.Query: Display Nth Raw data from table: suppose 7th row data i need(i.e 77 output)
        Table Name[test1]
        INV_no
          11      (1st)
          22      (2nd)
          33
          44
          55
          66
          77      (7th)
          88
          99

        SqlDataAdapter adp = new SqlDataAdapter("SELECT * FROM (SELECT row_number() OVER (ORDER BY INV_no ASC) AS row, * FROM test1) AS foo WHERE row = 7 ", con);
    Or,,
        SqlDataAdapter adp = new SqlDataAdapter("WITH Temp AS(SELECT ROW_NUMBER() OVER(ORDER BY INV_no ASC) AS RowNo, INV_no FROM test1 ) SELECT test1.* FROM test1 INNER JOIN Temp ON Temp.INV_no = test1.INV_no where RowNo='7'", con);

        6.Query:{Single Query}
Fetch data from a table-A and inserted into another table-B.Both table structure & type should be same.
SqlCommand cmd456 = new SqlCommand("insert into [xyz] select * from [abc] where ian_no= '335/20-21' ", con302);

        7.Query: TOP 5 Datas to be shown when data are in Assending order. (Output:     11,22,33,44,55)
        //SqlDataAdapter adp = new SqlDataAdapter("select Top 5 * From (Select Top (5) * from test1 Order By INV_no  ASC) AS foo Order By INV_no  ASC", con);

        8.A) Query: How to find ALL Non-Matching records from two tables in sql
        SqlDataAdapter adp = new SqlDataAdapter(" (select * from test1 except select * from test2)  union  (select * from test2 except select * from test1) ", con);
        8.B) Query:How to find ALL LeftTable(test1) Non-Matching records from two tables(test1, test2) in sql
         SqlDataAdapter adp = new SqlDataAdapter("select * from test1 where INV_no not in (select INV_no from test2) ", con);
        8.C) Query:How to find ALL RightTable(test2) Non-Matching records from two tables(test1, test2) in sql
         SqlDataAdapter adp = new SqlDataAdapter("select * from test2 where INV_no not in (select INV_no from test1) ", con); SQL Server-2016:

 

9.) Between Use:
  //SqlDataAdapter adp = new SqlDataAdapter("select a.number from [test_2] as a where a.number BETWEEN 100 and 400", con); 

10) All datas fetching from [i_pending_rl] and inserting into table [deleted_i_pending_rl]  where [condition].
Both table structure must be same.

SqlCommand cmd5121 = new SqlCommand("insert into [deleted_i_pending_rl] select * from i_pending_rl where order_no = '" + DropDownList1.Text + "'", con);
                                cmd5121.ExecuteNonQuery();

 

FAQ--(ASP. Net)

BACK

 ASP.Net with C#

1) Life Cycle of Asp.Net explain with example.

2) Execution Flow of Asp.Net (CLR/ GC/ Assemble/ .exe or .dll)

3) State Managements in Asp.Net(Client side/ Server side).

4) Response.Redirect and Response.Transfer in Asp.Net.

5) Web.Config Connection Strings  Settings.(Machine.config and Web.config)

6)  Authentications:(Window Authentication), (Form Authentication) and (Passport Authentication),           (None) And Authorizations Concept in Asp.Net

7) Security : Authentication And Authorization in Asp.Net.

8) To make fast Performance what should use.

9) IsPostBack Use.

10) Make a DropDownList inside a GridView.

11) Data Format to save a image in sql.

12) Cache in Asp.Net.

11) Validation in Asp.net (Client side-Javascript / Server side-6 types are there).

12) Global.asax  use.

13) What are the Navigate technic in Asp.Net.

        (Response.redirect/Server.Transfer/Server.Execute/Hyperlink/Window.Open)

14) Can a web application RUN without a web.config file (YES)

15) How can improve the fast asp.net pages.

14) Exception handling. (code Level/ page Level/ Application Level/ Custom).


 

FAQ--(C# .Net)

BACK

C# .Net:

All FAQ Lists-
 
1) OOP's ( Object Oriented Programming ) Concepts.
2) Boxing and Unboxing Concept in C#.
3) Value Type and reference type in C#. (Ref/Out Keyword) what do you means by Value Type and               Reference Type in C#.                   
4) Access Modifier in C#.
5) Nullable type in C#.
6) Sealed Class.
7) Properties in C#.
8) Indexes in C#.
9) Static Method and Class && Static variable.
10 Constant and Read-only.  (Very imp)
11) Serialization and deserialization in C#.
12) Partial Class.
13) Collection   & Generic Collection. (Array / ArrayList / List)
 
Pending Questions Below :-
1.How you will manage the Security for the application?

2.When we should use abstract and when Interface in real time project.

3.How to improve the performance of your application?

4.Differences between ReadOnly and Constant Keyword in C# .


Most IMP Questions Below :-

1. What is OOP"s Concept ? Explain with Examples and Coding.

Ans: OOP( Object Oriented Programming in C# .NET. )

OOP's Concepts:

  • 1.Encapsulation
  • 2. Abstraction 
  • 3. Inheritance
  • 4. Polymorphism
  • 5. Dynamic Binding
  • 6. Message Passing.
1. Encapsulation:
Rapping the data members and member function into a container(or Class) is called encapsulation. 
In Encapsulation, the variables or data of a class are hidden from any other class and can be accessed only through any member function of their class in which they are declared. As in encapsulation, the data in a class is hidden from other classes, so it is also known as data-hiding. The data are hide (restricted) by using access modifier (public/private/protected/internal/protected internal).
EX: A class is rapping the data members (variables, types etc.) and member function (methods) in it. So everything is inside the class only.

Class ABC
{
    
    // it can be accessible outside the class possible
    private x=10, y=20; 
    protected void show()
        {
            int a=100;
            int b=200;
        }
}

2. Abstraction :
Abstraction is achieved by using the abstract classes and abstract methods in c#.
An abstract class is an incomplete class or special class we can’t be instantiated. The purpose of an abstract class is to provide a blueprint for derived classes and set some rules what the derived classes must implement when they inherit an abstract class. We can use an abstract class as a base class and all derived classes must implement abstract definitions. 

Points to be remember:
1.An Abstract class does not mean that it only contain abstract methods. An Abstract class can also contain non-abstract methods also.
2. Abstract class can also work with get and set accessory.
  • A user must use the override keyword before the method which is declared as abstract in child class, the abstract class is used to inherit in the child class.
  • An abstract class cannot be inherited by structures.
  • It can contains constructors or destructors.
  • It can implement functions with non-Abstract methods.
  • It cannot support multiple inheritance.
  • It can’t be static
  • .
3. Inheritance: (Reusability of the CODE)
It can be possible to re-use the same code written in a class in another class by using Inheritance.
  • Super Class: The class whose features are inherited is known as super class(or a base class or a parent class).
  • Sub Class: The class that inherits the other class is known as subclass(or a derived class, extended class, or child class). The subclass can add its own fields and methods in addition to the superclass fields and methods.

Syntax:  (Symbol of inheritance is colon : )

class derived-class : base-class  
{  
   // methods and fields  
      .....
}
 Types of Inheritance in C#
    - Single Inheritance
    - Multilevel Inheritance.
    - Hierarchical Inheritance.

*Single Inheritance: In single inheritance, subclasses inherit the features of one superclass. In image below, the class A serves as a base class for the derived class
 
*Multilevel Inheritance: In Multilevel Inheritance, a derived class will be inheriting a base class and as well as the derived class also act as the base class to other class. In below image, class A serves as a base class for the derived class B, which in turn serves as a base class for the derived class C.
 
 
 

 
*Hierarchical Inheritance: In Hierarchical Inheritance, one class serves as a superclass (base class) for more than one subclass. In below image, class A serves as a base class for the derived class B, C, and D. 

*Multiple Inheritance(Through Interfaces):In Multiple inheritance, one class can have more than one superclass and inherit features from all parent classes. Please note that C# does not support multiple inheritance with classes. In C#, we can achieve multiple inheritance only through Interfaces. In the image below, Class C is derived from interface A and B.
  1. *Hybrid Inheritance(Through Interfaces): It is a mix of two or more of the above types of inheritance. Since C# doesn’t support multiple inheritance with classes, the hybrid inheritance is also not possible with classes. In C#, we can achieve hybrid inheritance only through Interfaces.



IMPORTANT Points:

a) A superclass can have any number of subclasses. But a subclass can have only one superclass. This is because C# does not support multiple inheritance with classes. Although with interfaces, multiple inheritance is supported
b) A subclass inherits all the members (fields, methods) from its superclass. Constructors are not members, so they are not inherited by subclasses, but the constructor of the superclass can be invoked from the subclass.
c) A subclass does not inherit the private members of its parent class. However, if the superclass has properties(get and set methods) for accessing its private fields, then a subclass can inherit.

4. Polymorphism:
Poly means "many" and morphs means "forms" -- Many Forms
So one name but different forms.

POINTS to be noted-- For Overloading:
Main Point : The method parameter can not be same and can not be same order.

1.) Method overloading : When the multiple methods having the same method name but different signature(parameters) is called overloading. most important if the
method name and signature also same then the program will throw compile time error like ""The program is ambiguous because it is already define a member as sum(method name) with the same parameter type". you cannot declare two methods with the same signature and different return type.
EX:
using System;

public class Program
{
public void load(int x, int y)
{
Console.WriteLine(x+y);
}
public void load(int a, int b)
{
Console.WriteLine(a+b);
}

public static void Main()
{
Program  obj=new Program();
obj.load(10,30);
Console.WriteLine(obj);
}
}

2) Why do we need Method Overloading?

If we need to do the same kind of the operation in different ways i.e. for different inputs. In the example described below, we are doing the addition operation for different inputs. It is hard to find many different meaningful names for single action.


POINTS to be noted for Overriding:

1.) A derived class can override a base class member only if the base class member is declared as virtual or abstract.


POINTS For Virtual/ Override/ Base       Keyword Use:

In C# we can use 3 types of keywords for Method Overriding:

  • virtual keyword: This modifier or keyword use within base class method. It is used to modify a method in base class for overridden that particular method in the derived class.
  • override: This modifier or keyword use with derived class method. It is used to modify a virtual or abstract method into derived class which presents in base class.
  • base Keyword: This is used to access members of the base class from derived class. It basically used to access constructors and methods or functions of the base class. The base keyword cannot use within a static method. Base keyword specifies which constructor of the base class should be invoked while creating the instances of the derived class.

Use of Base keyword: 

  • Call methods or functions of base class from derived class.
  • Call constructor internally of base class at the time of inheritance.


  • Paul Blog
  • FAQ--(3- Tier Project)

    BACK   https://meeraacademy.com/3-tier-architecture-example-in-asp-net-c/ 1. Presentation Layer (UI – User Interface Layer) 2. Busine...