Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C#

abstract: practical reference

abstract: practical reference: abstract marks an incomplete type or member that requires implementation in a derived class.

Version: C# language and .NET 10 reference runtime

Syntax

abstract /* grammar-specific form */

abstract marks an incomplete type or member that requires implementation in a derived class.

Use it for a shared contract with a partial implementation.

An abstract class cannot be instantiated; an abstract member is virtual and has no body.

A concrete class must implement every abstract member.

The complete program actually uses abstract; its exact expected stdout is 4.

Examples

using System;
using System.Buffers;
using System.Collections.Concurrent;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Number = System.Int32;

Console.WriteLine(new Concrete().Value);
abstract class Base { public abstract int Value { get; } }
sealed class Concrete : Base { public override int Value => 4; }

Result

4

The complete program actually uses `abstract`; its exact expected stdout is `4`.

Sources