Click here to Skip to main content
15,888,113 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionCode for reading Weight from a scale using serial cable RS2 Pin
Member 1190617212-Aug-15 22:16
Member 1190617212-Aug-15 22:16 
AnswerRe: Code for reading Weight from a scale using serial cable RS2 Pin
Richard MacCutchan12-Aug-15 22:59
mveRichard MacCutchan12-Aug-15 22:59 
Questionc#.net meeting request cancellation Pin
Karan_TN12-Aug-15 3:16
Karan_TN12-Aug-15 3:16 
AnswerRe: c#.net meeting request cancellation Pin
F-ES Sitecore12-Aug-15 3:51
professionalF-ES Sitecore12-Aug-15 3:51 
GeneralRe: c#.net meeting request cancellation Pin
Karan_TN12-Aug-15 18:57
Karan_TN12-Aug-15 18:57 
GeneralRe: c#.net meeting request cancellation Pin
Blikkies13-Aug-15 0:37
professionalBlikkies13-Aug-15 0:37 
GeneralRe: c#.net meeting request cancellation Pin
Karan_TN13-Aug-15 0:43
Karan_TN13-Aug-15 0:43 
QuestionDifference between Abstract Method and Virtual Method ? Pin
Pushkar Kumar Singh10-Aug-15 6:01
Pushkar Kumar Singh10-Aug-15 6:01 
The differences between Virtual method and Abstract method are as follows:

  1. In class, Abstract method has no body but Virtual method has body.
  2. Abstract method can be declared in Abstract class only but there is no need of Abstract class for Virtual method.
  3. Abstract method must be override in Derived class but Virtual method may be override or not.
  4. Abstract method is also called Pure Virtual Method
  5. Abstract method must be declared in Abstract class, we did not create an object of Abstract class.
Demo:-
using System;
namespace LearnProject
{

    abstract class TestClassA
    {
          public void Method1()
        {
            Console.WriteLine("I am in Method1() of TestClassA ");
        }
          public virtual void Method2()
          {
              Console.WriteLine("I am in Method2() of TestClassA ");
          }

          public abstract void Method3();

    }

    class TestClassB : TestClassA
    {
        public  override void Method2()
        {
            Console.WriteLine("I am in Method2() of TestClassB ");
        }

        public override void Method3()
        {
            Console.WriteLine("I am in Method3() of TestClassB ");
        }
    }

    class Abstract_and_Virtual_methods
    {
        public static  void Main()
        {

            TestClassB testClassB = new TestClassB();
            testClassB.Method1();
            testClassB.Method2();
            testClassB.Method3();

            TestClassA testClassA = new TestClassB();
            testClassB.Method1();
            testClassA.Method2();
            testClassA.Method3();

            // TestClassB b = new TestClassA() is not allowed

            TestClassB b = new TestClassB(); 
            b = testClassB; // Object of TestClassB is assigned

            b = testClassA as TestClassB; //  Here We need type cast 

            Console.Read();
        }
    }
}

In the above program, we create three methods in the TestclassA, We override virtual method Method2() and abstract method Method3() in the derived class TestClassB.

Output :-
I am in Method1() of TestClassA
I am in Method2() of TestClassB
I am in Method3() of TestClassB
I am in Method1() of TestClassA
I am in Method2() of TestClassB
I am in Method3() of TestClassB

Note:- If we did not override the virtual method - Method2() of TestClassA in the derived class TestClassB, then output would be as follows :

I am in Method1() of TestClassA
I am in Method2() of TestClassB
I am in Method3() of TestClassB
I am in Method1() of TestClassA
I am in Method2() of TestClassA
I am in Method3() of TestClassB
GeneralRe: Difference between Abstract Method and Virtual Method ? Pin
PIEBALDconsult10-Aug-15 6:08
mvePIEBALDconsult10-Aug-15 6:08 
Questionpersist changes by javascript on postback in asp.net Pin
Rahul Prajapat8-Aug-15 16:32
Rahul Prajapat8-Aug-15 16:32 
AnswerRe: persist changes by javascript on postback in asp.net Pin
F-ES Sitecore9-Aug-15 1:08
professionalF-ES Sitecore9-Aug-15 1:08 
QuestionConsole Application in C# Pin
PRAKAS PANDEY8-Aug-15 4:09
PRAKAS PANDEY8-Aug-15 4:09 
AnswerRe: Console Application in C# Pin
Ravi Bhavnani8-Aug-15 5:00
professionalRavi Bhavnani8-Aug-15 5:00 
AnswerRe: Console Application in C# Pin
User 418025410-Aug-15 9:11
User 418025410-Aug-15 9:11 
QuestionHow to go to next Page while hitting the next button without selecting a value in the current page? Pin
Member 118937297-Aug-15 8:27
Member 118937297-Aug-15 8:27 
AnswerRe: How to go to next Page while hitting the next button without selecting a value in the current page? Pin
jkirkerx7-Aug-15 8:55
professionaljkirkerx7-Aug-15 8:55 
GeneralRe: How to go to next Page while hitting the next button without selecting a value in the current page? Pin
Member 118937297-Aug-15 9:19
Member 118937297-Aug-15 9:19 
GeneralRe: How to go to next Page while hitting the next button without selecting a value in the current page? Pin
jkirkerx7-Aug-15 12:41
professionaljkirkerx7-Aug-15 12:41 
GeneralRe: How to go to next Page while hitting the next button without selecting a value in the current page? Pin
jkirkerx8-Aug-15 8:30
professionaljkirkerx8-Aug-15 8:30 
GeneralRe: How to go to next Page while hitting the next button without selecting a value in the current page? Pin
Member 1189372910-Aug-15 8:31
Member 1189372910-Aug-15 8:31 
GeneralRe: How to go to next Page while hitting the next button without selecting a value in the current page? Pin
jkirkerx10-Aug-15 9:48
professionaljkirkerx10-Aug-15 9:48 
GeneralRe: How to go to next Page while hitting the next button without selecting a value in the current page? Pin
Member 1189372910-Aug-15 9:57
Member 1189372910-Aug-15 9:57 
GeneralRe: How to go to next Page while hitting the next button without selecting a value in the current page? Pin
jkirkerx10-Aug-15 11:09
professionaljkirkerx10-Aug-15 11:09 
GeneralRe: How to go to next Page while hitting the next button without selecting a value in the current page? Pin
Member 1189372910-Aug-15 11:32
Member 1189372910-Aug-15 11:32 
GeneralRe: How to go to next Page while hitting the next button without selecting a value in the current page? Pin
jkirkerx10-Aug-15 12:10
professionaljkirkerx10-Aug-15 12:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.