Share via


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 Building Console Applications.

  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

Reference

Implement Abstract Base Class

StringComparer

Other Resources

Automatic Code Generation