Monday, 9 December 2013

Count Number of Visitors in Website using Asp.net in C#

Follow these steps :1,
Open Visual Studio à Create New Website à Right click on Solution Explorer à Select Add New Item à Select Global Application Class file and click 

Step :2,

In Global.ascx page do these changes


void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
Application["NoOfApplicationVisitors"] = 0;
}

void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started
Application.Lock();
Application["NoOfApplicationVisitors"] = (int)Application["NoOfApplicationVisitors"] + 1;
Application.UnLock();
}

Step:3, in aspx page



<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<table>
<tr>
<td>
<b>No of Visits in your application:</b>
</td>
<td>
<asp:Label ID="lblUserCount" runat="server" ForeColor="Red" />
</td>
</tr>
</table>
</form>
</body>
</html>

Step:4, in aspx.cs  code behind page



protected void Page_Load(object sender, EventArgs e)
{
lblUserCount.Text = Application["NoOfApplicationVisitors"].ToString();
}

Now you can execute and check.


Monday, 11 November 2013

alignment issue words without having space with browser compatability

Add this css class 
.wordbreak
{
    word-break:break-all;
    word-wrap:break-word;
    -ms-word-break:break-all;
    -ms-word-wrap:break-word;
    overflow-wrap:break-word;
}

In View
<td  class="wbrk">
                    @Html.LabelFor(model => model.Name)
                </td>

Wednesday, 30 October 2013

how to update windows 8 to 8.1 step by step procedure

Simple steps for upgrade windows 8.0 to 8.1
1.first select windows 8 home screen
2.select Store
3.you can see the windows 8.1 update
4.select that , after select download button will be press that button.
5. downloading process will be
6. after that restart will ask , just restart your system.

Sunday, 27 October 2013

placeholder attribute browser compatibility issue with ie

in jquery document.ready function add this function, this method detect control and attribute and it will apply to the entire application controls,

/* Placeholders.js v3.0.0 */
(function(t){"use strict";function e(t,e,r){return t.addEventListener?t.addEventListener(e,r,!1):t.attachEvent?t.attachEvent("on"+e,r):void 0}function r(t,e){var r,n;for(r=0,n=t.length;n>r;r++)if(t[r]===e)return!0;return!1}function n(t,e){var r;t.createTextRange?(r=t.createTextRange(),r.move("character",e),r.select()):t.selectionStart&&(t.focus(),t.setSelectionRange(e,e))}function a(t,e){try{return t.type=e,!0}catch(r){return!1}}t.Placeholders={Utils:{addEventListener:e,inArray:r,moveCaret:n,changeType:a}}})(this),function(t){"use strict";function e(){}function r(t,e){var r,n,a=!!e&&t.value!==e,u=t.value===t.getAttribute(V);return(a||u)&&"true"===t.getAttribute(D)?(t.removeAttribute(D),t.value=t.value.replace(t.getAttribute(V),""),t.className=t.className.replace(R,""),n=t.getAttribute(z),n&&(t.setAttribute("maxLength",n),t.removeAttribute(z)),r=t.getAttribute(I),r&&(t.type=r),!0):!1}function n(t){var e,r,n=t.getAttribute(V);return""===t.value&&n?(t.setAttribute(D,"true"),t.value=n,t.className+=" "+k,r=t.getAttribute(z),r||(t.setAttribute(z,t.maxLength),t.removeAttribute("maxLength")),e=t.getAttribute(I),e?t.type="text":"password"===t.type&&K.changeType(t,"text")&&t.setAttribute(I,"password"),!0):!1}function a(t,e){var r,n,a,u,i;if(t&&t.getAttribute(V))e(t);else for(r=t?t.getElementsByTagName("input"):p,n=t?t.getElementsByTagName("textarea"):b,i=0,u=r.length+n.length;u>i;i++)a=r.length>i?r[i]:n[i-r.length],e(a)}function u(t){a(t,r)}function i(t){a(t,n)}function l(t){return function(){m&&t.value===t.getAttribute(V)&&"true"===t.getAttribute(D)?K.moveCaret(t,0):r(t)}}function o(t){return function(){n(t)}}function c(t){return function(e){return f=t.value,"true"===t.getAttribute(D)&&f===t.getAttribute(V)&&K.inArray(C,e.keyCode)?(e.preventDefault&&e.preventDefault(),!1):void 0}}function s(t){return function(){r(t,f),""===t.value&&(t.blur(),K.moveCaret(t,0))}}function d(t){return function(){t===document.activeElement&&t.value===t.getAttribute(V)&&"true"===t.getAttribute(D)&&K.moveCaret(t,0)}}function g(t){return function(){u(t)}}function v(t){t.form&&(L=t.form,L.getAttribute(P)||(K.addEventListener(L,"submit",g(L)),L.setAttribute(P,"true"))),K.addEventListener(t,"focus",l(t)),K.addEventListener(t,"blur",o(t)),m&&(K.addEventListener(t,"keydown",c(t)),K.addEventListener(t,"keyup",s(t)),K.addEventListener(t,"click",d(t))),t.setAttribute(U,"true"),t.setAttribute(V,E),(m||t!==document.activeElement)&&n(t)}var p,b,m,h,f,A,y,E,x,L,T,N,S,w=["text","search","url","tel","email","password","number","textarea"],C=[27,33,34,35,36,37,38,39,40,8,46],B="#ccc",k="placeholdersjs",R=RegExp("(?:^|\\s)"+k+"(?!\\S)"),V="data-placeholder-value",D="data-placeholder-active",I="data-placeholder-type",P="data-placeholder-submit",U="data-placeholder-bound",j="data-placeholder-focus",q="data-placeholder-live",z="data-placeholder-maxlength",F=document.createElement("input"),G=document.getElementsByTagName("head")[0],H=document.documentElement,J=t.Placeholders,K=J.Utils;if(J.nativeSupport=void 0!==F.placeholder,!J.nativeSupport){for(p=document.getElementsByTagName("input"),b=document.getElementsByTagName("textarea"),m="false"===H.getAttribute(j),h="false"!==H.getAttribute(q),A=document.createElement("style"),A.type="text/css",y=document.createTextNode("."+k+" { color:"+B+"; }"),A.styleSheet?A.styleSheet.cssText=y.nodeValue:A.appendChild(y),G.insertBefore(A,G.firstChild),S=0,N=p.length+b.length;N>S;S++)T=p.length>S?p[S]:b[S-p.length],E=T.attributes.placeholder,E&&(E=E.nodeValue,E&&K.inArray(w,T.type)&&v(T));x=setInterval(function(){for(S=0,N=p.length+b.length;N>S;S++)T=p.length>S?p[S]:b[S-p.length],E=T.attributes.placeholder,E?(E=E.nodeValue,E&&K.inArray(w,T.type)&&(T.getAttribute(U)||v(T),(E!==T.getAttribute(V)||"password"===T.type&&!T.getAttribute(I))&&("password"===T.type&&!T.getAttribute(I)&&K.changeType(T,"text")&&T.setAttribute(I,"password"),T.value===T.getAttribute(V)&&(T.value=E),T.setAttribute(V,E)))):T.getAttribute(D)&&(r(T),T.removeAttribute(V));h||clearInterval(x)},100)}J.disable=J.nativeSupport?e:u,J.enable=J.nativeSupport?e:i}(this);

Monday, 14 October 2013

Disabling validation in @Html.TextBoxFor in MVC

follow this
@Html.TextBoxFor(m => m.dtEndDate, new { id = "ID", data_val = "false" })

Tuesday, 8 October 2013

bind enum values to dropdownlist in mvc3

First Create enum
public enum test
    {
        [Description("test1")]
        test1= 0,
        [Description("test2")]
        test= 1 ,
        [Description("test3")]
        test= 2 ,
        [Description("test4")]
        test= 3
    }

Assign Enum value to view

@Html.DropDownList("test", (from test in Enum.GetValues(typeof(test))
                                                      select new SelectListItem { Value = ((int)test).ToString(), Text = test.GetDescription() }))

Wednesday, 25 September 2013

uninstall nuget package visual studio, uninstall nuget package vs 2010

follow this ,
C:\Program Files (x86)\Microsoft Visual Studio10.0\Common7\IDE\Extensions\Microsoft Corporation\NuGet Package Manager

Tuesday, 17 September 2013

SQL Server - Acid Properties (Atomicity, Consistency, Isolation, Durability).

Atomicity

It is one unit of work and does not dependent on previous and following transactions. This transaction is either fully completed or not begun at all. Any updates in the system during transaction will complete entirely. If any reason an error occurs and the transaction is unable to complete all of its steps, then the system will returned to the state where transaction was started

Consistency

Data is either committed or roll back, not “in-between” case where something has been updated and something hasn’t and it will never leave your database till transaction finished. If the transaction completes successfully, then all changes to the system will have been properly made, and the system will be in a valid state. If any error occurs in a transaction, then any changes already made will be automatically rolled back. This will return the system to its state before the transaction was started. Since the system was in a consistent state when the transaction was started, it will once again be in a consistent state.

Isolation

No transaction sees the intermediate results of the current transaction. We have two transactions both are performing the same function and running at the same time, the isolation will ensure that each transaction separate from other until both are finished.

Durability

Once transaction completed whatever the changes made to the system will be permanent even if the system crashes right after

Whenever transaction will start each will obey all the acid properties.

Thursday, 12 September 2013

Types of Cursors


  • Static Cursors

    A static cursor populates the result set at the time of cursor creation and query result is cached for the lifetime of the cursor. A static cursor can move forward and backward direction. A static cursor is slower and use more memory in comparison to other cursor. Hence you should use it only if scrolling is required and other types of cursors are not suitable.
    You can't update, delete data using static cursor. It is not sensitive to any changes to the original data source. By default static cursors are scrollable.
  • Dynamic Cursors

    A dynamic cursor allows you to see the data updation, deletion and insertion in the data source while the cursor is open. Hence a dynamic cursor is sensitive to any changes to the data source and supports update, delete operations. By default dynamic cursors are scrollable.
  • Forward Only Cursors

    A forward only cursor is the fastest cursor among the all cursors but it doesn't support backward scrolling. You can update, delete data using Forward Only cursor. It is sensitive to any changes to the original data source.
    There are three more types of Forward Only Cursors.Forward_Only KEYSET, FORWARD_ONLY STATIC and FAST_FORWARD.
    FORWARD_ONLY STATIC Cursor is populated at the time of creation and cached the data to the cursor lifetime. It is not sensitive to any changes to the data source.
    FAST_FORWARD Cursor is the fastest cursor and it is not sensitive to any changes to the data source.
  • Keyset Driven Cursors

    A keyset driven cursor is controlled by a set of unique identifiers as the keys in the keyset. The keyset depends on all the rows that qualified the SELECT statement at the time of cursor was opened. A keyset driven cursor is sensitive to any changes to the data source and supports update, delete operations. By default keyset driven cursors are scrollable.
  • Swap the values of two columns in SQL Server


    Do you have fun with SQL Server?. Let's start fun with SQL Server. Suppose you want to swap the values of two columns of a table in SQL Server, how could you achieve this tricky task?. Actually, it is simple and so funny.
    Suppose you have a Customer table in the database with the following data and you want to interchange the values of columns Name and Address then how do you do?
    1. SELECT * FROM CUSTOMER

    Don't worry, to do this task, you need to just write a simple update query for Customer table like as :
    1. UPDATE Customer SET Name=Address , Address=Name
    Now After query execution you will find the the values of columns Name and Address have been interchanged, that's so cool.
    1. SELECT * FROM CUSTOMER

    referred from dot net tricks

    Tuesday, 27 August 2013

    What is ref keyword in C#

    What is “ref” keyword in C#

    “ref Keyword” in C#.

    Passing variables by value is the default. However, we can force the value parameter to be passed by reference. 

    Point to be kept in mind while using ref keyword.
    variable “must” be initialized before it is passed into a method.


    Example, Without Using ref keyword
    class Test
    {
    public static void Main()
    {
    int a = 1;
    DoWork(a);
    Console.WriteLine("The value of a is " + a); 
    }

    public static void DoWork(int i)
    {
    i++;
    }
    }
    The program will result in : The value of a is 1


    Example, With the Use of ref keyword
    class Test
    {
    public static void Main()
    {
    int a = 2; // must be initialized
    DoWork(ref a); // note ref Keyword
    Console.WriteLine("The value of a is " + a); 
    }

    public static void DoWork(ref int i) // note ref Keyword
    {
    i++;
    }
    }
    The program will result : The value of a is 3

    What is “out” keyword in C#

    What is “out” keyword in C#

    “out Keyword” in C#.

    out keyword is used for passing a variable for output purpose. It has same concept as ref keyword, but passing a ref parameter needs variable to be initialized while out parameter is passed without initialized. 
    It is useful when we want to return more than one value from the method.

    Point to be kept in mind while using out keyword.
    You must assigned value to out parameter in method body, otherwise the method won’t compiled.

    Example of “out keyword”:
    class Test
    {
    public static void Main()
    {
    int a; // may be left un-initialized
    DoWork(out a); // note out keyword
    Console.WriteLine("The value of a is " + a); 
    }

    public static void DoWork(out int i) // note out keyword
    {
    i=12; //must assigned value.
    }
    }

    The program will result : The value of a is 12

    Wednesday, 31 July 2013

    convert datetime to utc in c#

    Use This

    DateTime dtUTC = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);

    Sunday, 21 July 2013

    ternary operator in c# example

    Syntex:
    condition ? con1 : con2
    
    
    
    
    
    
    
    Examples:
    
    
    
    
    
    
    string Name="fhsdfh hsjk dhfsjkahfsklfdhasklh shfkjsha sdfg sadgf sagsad";
    
    
    string DisplayName = Name.Length > 50 ? Name.Substring(0, 50) + "..." : Name;
    
    
    Output:
    
    
    If Name character morethan 50 return -> fhsdfh hsjk dhfsjkahfsklfdhasklh...
    Else                                      -> Name
    
    

    package microsoft sql server failed to load [SOLVED]

    Solution 1:

    this problem may happen due to antivirus may delete some framework set-up files.

    Just download .net framework 2.0 and install. after that it will work as usual.

    Solution 2:

    Repair your server.

    Thursday, 18 July 2013

    oops

    Class
    A user-defined data structure that groups properties and methods. Class doesn’t occupies memory.

    Object

    Instance of Class is called object. An object is created in memory using keyword “new”.

    Difference between Struct and Class

    • Struct are Value type and are stored on stack, while Class are Reference type and are stored on heap.
    • Struct “do not support” inheritance, while class supports inheritance. However struct can implementsinterface

      .
    • Struct should be used when you want to use a small data structure, while Class is better choice for complex data structure.


    What is the difference between instantiating structures with and without using the new keyword?
    When a structure is instantiated using the new keyword, a constructor (no-argument or custom, if provided) is called which initializes the fields in the structure. When a structure is instantiated without using the new keyword, no constructor is called. Hence, one has to explicitly initialize all the fields of the structure before using it when instantiated without the new keyword.

    Encapsulation

    Wrapping up of data and function into a single unit is known as Encapsulation.

    Properties

    Attribute of object is called properties. Eg1:- A car has color as property.
    Eg2:
    private string m_Color;;
    public string Color
    {
    get
    {
    return m_Color;
    }
    set
    {
    m_Color = value;
    }
    }
    Car Maruti = new Car();
    Maruti.Color= “White”;
    Console.Write(Maruti.Color);

    Isn't it better to make a field public than providing its property with
     both set { } and get { } block? After all the property will allow the user to 
    both read and modify the field so why not use public field instead? Motivate your answer
    
    Not always! Properties are not just to provide access to the fields; 
    rather, they are supposed to provide controlled access to the fields of our class. 
    As the state of the class depends upon the values of its fields, using properties 
    we can assure that no invalid (or unacceptable) value is assigned to the fields.
    Eg:
    private int age;
    public int Age
    {
    get
    {
    return age;
    }
    set
    {
    if(value <> 100)
    //throw exception
    else
    age = value;
    }
    }
     
    this Keyword
    Each object has a reference “this” which points to itself.
    Two uses of this keyword.
    o Can be used to refer to the current object.
    o It can also be used by one constructor to explicitly invoke another constructor of the same class.
    Eg1:
    class Student
    {
    private string name;
    private int age;
    Student(string name, int age)
    {
    this.name = name;
    this.age = age;
    }
    }
    Eg2:
    class Circle
    {
    double x,y,radius;
    Circle(double x){
    this(x,0,1);
    }
    Circle(double x, double y){
    this(x,y,1);
    }
    Circle(double x, double y, double radius){
    this.x = x;
    this.y = y;
    this.radius = radius;
    }
    }

    Constructor

    • A constructor is a special method whose task is to initialize the object of its class.
    • It is special because its name is the same as the class name.
    • They do not have return types, not even void and therefore they cannot return values.
    • They cannot be inherited, though a derived class can call the base class constructor.
    • Constructor is invoked whenever an object of its associated class is created.
    • Note: There is always atleast one constructor in every class. If you do not write a constructor, C# automatically provides one for you, this is called default constructor. Eg: class A, default constructor is A().

    Static Members of the class

    Static members belong to the whole class rather than to individual object

    Static members are accessed with the name of class rather than reference to objects.
    Eg:
    class Test
    {
    public int rollNo;
    public int mathsMarks;
    public static int totalMathMarks;
    }
    class TestDemo
    {
    public static void main()
    {
    Test stud1 = new Test();
    stud1.rollNo = 1;
    stud1.mathsMarks = 40;
    stud2.rollNo = 2;
    stud2.mathsMarks = 43;
    Test.totalMathsMarks = stud1.mathsMarks + stud2.mathsMarks;
    }
    }

    Static Method of the class

    Methods that you can call directly without first creating an instance of a class. Eg: Main() Method, Console.WriteLine()
    You can use static fields, methods, properties and even constructors which will be called before any instance of the class is created.
    As static methods may be called without any reference to object, you can not use instance members inside static methods or properties, while you may call a static member from a non-static context. The reason for being able to call static members from non-static context is that static members belong to the class and are present irrespective of the existence of even a single object.

    Static Constructor

    In C# it is possible to write a static no-parameter constructor for a class. Such a class is executed once, when first object of class is created.
    One reason for writing a static constructor would be if your class has some static fields or properties that need to be initialized from an external source before the class is first used.
    Eg:
    Class MyClass
    {
    static MyClass()
    {
    //Initialization Code for static fields and properties.
    }
    }
    Finalize() Method of Object classEach class in C# is automatically (implicitly) inherited from the Object class which contains a method Finalize(). This method is guaranteed to be called when your object is garbage collected (removed from memory). You can override this method and put here code for freeing resources that you reserved when using the object.
    For example
    Protected override void Finalize()
    {
    try
    {
    Console.WriteLine(“Destructing Object….”);
    //put some code here.
    }
    finally
    {
    base.Finalize();
    }
    }

    Destructor

    A destructor is just opposite to constructor.
    It has same as the class name, but with prefix ~ (tilde).
    They do not have return types, not even void and therefore they cannot return values.
    destructor is invoked whenever an object is about to be garbage collected
    Eg:
    class person
    {
    //constructor
    person()
    {
    }
    //destructor
    ~person()
    {
    //put resource freeing code here.
    }
    }
    What is the difference between the destructor and the Finalize() method? When does the Finalize() method get called?
    Finalize() corresponds to the .Net Framework and is part of the System.Object class. Destructors are C#'s implementation of the Finalize() method. The functionality of both Finalize() and the destructor is the same, i.e., they contain code for freeing the resources when the object is about to be garbage collected. In C#, destructors are converted to the Finalize() method when the program is compiled. The Finalize() method is called by the .Net Runtime and we can not predict when it will be called. It is guaranteed to be called when there is no reference pointing to the object and the object is about to be garbage collected.

    Garbage Collection

    • Garbage collection is the mechanism that reclaims the memory resources of an object when it is no longer referenced by a variable.
    • .Net Runtime performs automatically performs garbage collection, however you can force the garbage collection to run at a certain point in your code by calling System.GC.Collect().
    • Advantage of Garbage collection : It prevents programming error that could otherwise occur by incorrectly deleting or failing to delete objects.


    Enumeration

    Enumeration improves code readability. It also helps in avoiding typing mistake.



    Concept of Heap and Stack

    Local Variables

    Stack

    Free Memory
    (Larger Memory Area than Stack).
    Heap
    Global Variables
    Permanent Storage area
    Program Instruction
    The Program Instruction and Global and Static variables are stored in a region known as permanent storage area and the local variables are stored in another area called stack. The memory space located between these two regions is available for dynamic memory allocation during execution of program. This free memory region is calledheap. The size of heap keeps on changing when program is executed due to creation and death of variables that are local to functions and blocks. Therefore, it is possible to encounter memory “overflow” during dynamic allocation process.

    Value Type and Reference Type
    A variable is value type or reference type is solely determined by its data type.
    Eg: int, float, char, decimal, bool, decimal, struct, etc are value types, while object type such as class, String, Array, etc are reference type.

    VALUE TYPE

    As name suggest Value Type stores “value” directly.
    For eg:
    //I and J are both of type int
    I = 20;
    J = I;
    int is a value type, which means that the above statements will results in two locations in memory.
    For each instance of value type separate memory is allocated.
    Stored in a Stack.
    It Provides Quick Access, because of value located on stack.

    REFERENCE TYPE

    As name suggest Reference Type stores “reference” to the value.
    For eg:
    Vector X, Y; //Object is defined. (No memory is allocated.)
    X = new Vector(); //Memory is allocated to Object. //(new is responsible for allocating memory.)
    X.value = 30; //Initialising value field in a vector class.
    Y = X; //Both X and Y points to same memory location. //No memory is created for Y.
    Console.writeline(Y.value); //displays 30, as both points to same memory
    Y.value = 50;
    Console.writeline(X.value); //displays 50.
    Note: If a variable is reference it is possible to indicate that it does not refer to any object by setting its value to null;
    Reference type are stored on Heap.
    It provides comparatively slower access, as value located on heap.
    ref keyword
    Passing variables by value is the default. However, we can force the value parameter to be passed by reference. Note: variable “must” be initialized before it is passed into a method.
    out keyword
    out keyword is used for passing a variable for output purpose. It has same concept as ref keyword, but passing a ref parameter needs variable to be initialized while out parameter is passed without initialized.
    It is useful when we want to return more than one value from the method.
    Note: You must assigned value to out parameter in method body, otherwise the method won’t compiled.


    Boxing and Un-Boxing

    Boxing: means converting value-type to reference-type.
    Eg:
    int I = 20;
    string s = I.ToSting();
    UnBoxing: means converting reference-type to value-type.
    Eg:
    int I = 20;
    string s = I.ToString(); //Box the int
    int J = Convert.ToInt32(s); //UnBox it back to an int.
    Note: Performance Overheads due to boxing and unboxing as the boxing makes a copy of value type from stack and place it inside an object of type System.Object in the heap.

    Inheritance

    The process of sub-classing a class to extend its functionality is called Inheritance.
    It provides idea of reusability.
    Order of Constructor execution in Inheritance
    constructors are called in the order from the top to the bottom (parent to child class) in inheritance hierarchy.
    Order of Destructor execution in Inheritance
    The destructors are called in the reverse order, i.e., from the bottom to the top (child to parent class) in the inheritance hierarchy.
    What are Sealed Classes in C#?The sealed modifier is used to prevent derivation from a class. A compile-time error occurs if a sealed class is specified as the base class of another class. (A sealed class cannot also be an abstract class)

    Can you prevent your class from being inherited by another class?Yes. The keyword “sealed” will prevent the class from being inherited.

    Can you allow a class to be inherited, but prevent the method from being over-ridden?Yes. Just leave the class public and make the method sealed.

    Fast Facts of Inheritance

    Multiple inheritance of classes is not allowed in C#.
    In C# you can implements more than one interface, thus multiple inheritance is achieved through interface.
    The Object class defined in the System namespace is implicitly the ultimate base class of all the classes in C# (and the .NET framework)
    Structures (struct) in C# does not support inheritance, it can only implements interfaces.

    Polymorphism

    Polymorphism means same operation may behave differently on different classes.
    Eg:
    Method Overloading is an example of Compile Time Polymorphism.
    Method Overriding is an example of Run Time Polymorphism
    Does C#.net supports multiple inheritance?
    No. A class can inherit from only one base class, however a class can implements many interface, which servers some of the same purpose without increasing complexity.
    How many types of Access Modifiers.
    1) Public – Allows the members to be globally accessible.
    2) Private – Limits the member’s access to only the containing type.
    3) Protected – Limits the member’s access to the containing type and all classes derived from the containing type.
    4) Internal – Limits the member’s access to within the current project.

    Method Overloading

    Method with same name but with different arguments is called method overloading.
    Method Overloading forms compile-time polymorphism.
    Eg:
    class A1
    {
    void hello()
    { Console.WriteLine(“Hello”); }
    void hello(string s)
    { Console.WriteLine(“Hello {0}”,s); }
    }

    Method Overriding

    Method overriding occurs when child class declares a method that has the same type arguments as a method declared by one of its superclass.
    Method overriding forms Run-time polymorphism.
    Note: By default functions are not virtual in C# and so you need to write “virtual” explicitly. While by default inJava each function are virtual.
    Eg1:
    Class parent
    {
    virtual void hello()
    { Console.WriteLine(“Hello from Parent”); }
    }
    Class child : parent
    {
    override void hello()
    { Console.WriteLine(“Hello from Child”); }
    }
    static void main()
    {
    parent objParent = new child();
    objParent.hello();
    }
    //Output
    Hello from Child.

    Virtual Method

    By declaring base class function as virtual, we allow the function to be overridden in any of derived class.
    Eg:
    Class parent
    {
    virtual void hello()
    { Console.WriteLine(“Hello from Parent”); }
    }
    Class child : parent
    {
    override void hello()
    { Console.WriteLine(“Hello from Child”); }
    }
    static void main()
    {
    parent objParent = new child();
    objParent.hello();
    }
    //Output
    Hello from Child.