Table of Contents

Class CodeBlock

Namespace
GenerativeAI.Core
Assembly
GenerativeAI.dll

Represents a segment of source code with details about its programming language and line number.

public class CodeBlock
Inheritance
CodeBlock
Inherited Members
Extension Methods

Constructors

CodeBlock(string, string)

Represents a block of code with its corresponding programming language and line number information.

public CodeBlock(string language, string code)

Parameters

language string
code string

CodeBlock(string, string, int)

Represents a block of code with its corresponding programming language and line number information.

public CodeBlock(string language, string code, int lineNumber)

Parameters

language string
code string
lineNumber int

Properties

Code

Gets or sets the content of the code block as a string.

public string Code { get; set; }

Property Value

string

Remarks

This property holds the actual code segment stored within the code block. It is typically paired with the Language property to describe the code and its programming language context.

Language

Gets or sets the programming language associated with the code block.

public string Language { get; set; }

Property Value

string

Remarks

This property specifies the language in which the code in the Code property is written. It helps in identifying and appropriately processing or highlighting the code based on its language.

LineNumber

Gets or sets the line number where the code block appears in the source text.

public int LineNumber { get; set; }

Property Value

int

Remarks

This property indicates the starting line number of a code block, providing contextual information about its location within the original source content.

Methods

ToString()

Returns a string representation of the CodeBlock object, including the programming language and the corresponding code in a formatted manner.

public override string ToString()

Returns

string

A string that contains the language of the code and the formatted code content.