2 out of 2 rated this helpful - Rate this topic

How to: Implement Abstract Base Classes 

Use this procedure to perform the Implement Abstract Base Class IntelliSense operation. For more information, see Implement Abstract Base Class.

To implement an abstract base class using IntelliSense

  1. Create a console application. For more information, see Console Application Template.

  2. Place the cursor after the class Program statement.

  3. Type : StringComparer so the class declaration becomes class Program : StringComparer.

  4. Click the smart tag under StringComparer, and click Implement abstract class 'System.StringComparer'.

    IntelliSense adds three override methods from the StringComparer class to the Program class.

    using System;
    using System.Collections.Generic;
    using System.Text;
    namespace ConsoleApplication1
    {
        class Program : StringComparer
        {
            static void Main(string[] args)
            {
    
                }
    
                public override int Compare(string x, string y)
                {
                    throw new Exception ("The method or operation is not implemented.");
                }
                
                public override bool Equals(string x, string y)
                {
                    throw new Exception ("The method or operation is not implemented.");
                }
                public override int GetHashCode(string obj)
                {
                    throw new Exception ("The method or operation is not implemented.");
                }
                
        }
    }
    

Example

A new console application created by the development environment begins with the following declaration.

using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
     class Program
     {
          static void Main(string[] args)
          {
     
          }
      }
}

See Also

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Advertisement