Skip to content

Commit 5fe0dc8

Browse files
committed
Highlight fix
1 parent be29071 commit 5fe0dc8

File tree

3 files changed

+14
-18
lines changed

3 files changed

+14
-18
lines changed

docs/CSharpDotNet/Generics/Basic-Syntax.md

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Generic constraints specify the requirements that a type parameter must satisfy.
4444

4545
Without constraints, the compiler cannot assume anything about `T`.
4646

47-
## Basic Syntax
47+
### Basic Syntax
4848

4949
```CSharp
5050
class MyClass<T> where T : ConstraintType
@@ -67,41 +67,41 @@ Constraint order must follow this pattern:
6767
3. Interfaces
6868
4. new()
6969

70-
## Common Constraint Types
70+
### Common Constraint Types
7171

72-
### Reference type constraint
72+
#### Reference type constraint
7373

7474
```CSharp
7575
where T : class
7676
```
7777

78-
### Value type constraint
78+
#### Value type constraint
7979

8080
```CSharp
8181
where T : struct
8282
```
8383

84-
### Parameterless constructor
84+
#### Parameterless constructor
8585

8686
```CSharp
8787
where T : new()
8888
```
8989

90-
### Inherit from a base class
90+
#### Inherit from a base class
9191

9292
```CSharp
9393
where T : BaseClass
9494
```
9595

96-
### Implement an interface
96+
#### Implement an interface
9797

9898
```CSharp
9999
where T : IDisposable
100100
```
101101

102-
## Why Constraints Are Needed
102+
### Why Constraints Are Needed
103103

104-
### Calling members that may not exist
104+
#### Calling members that may not exist
105105

106106
```CSharp
107107
void CloseItem<T>(T item)
@@ -117,7 +117,7 @@ void CloseItem<T>(T item) where T : IDisposable
117117
}
118118
```
119119

120-
### Creating instances of T
120+
#### Creating instances of T
121121

122122
```CSharp
123123
class Factory<T>
@@ -133,7 +133,7 @@ class Factory<T> where T : new()
133133
}
134134
```
135135

136-
## Method-Level Constraints
136+
### Method-Level Constraints
137137

138138
Constraints can also be applied to individual methods:
139139

@@ -143,9 +143,3 @@ public void Save<T>(T item) where T : IEntity
143143
item.Store();
144144
}
145145
```
146-
147-
## Summary
148-
149-
- Constraints define what a type parameter must support.
150-
- They ensure type safety for operations involving `T`.
151-
- Common constraints include: class, struct, new(), base classes, and interfaces.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
id: Generics
3+
title: Generics
34
---
45

56
# Generics in C#

docusaurus.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ const config: Config = {
148148
'c',
149149
'cpp',
150150
'java',
151-
'python'
151+
'python',
152+
'csharp'
152153
],
153154
},
154155
} satisfies Preset.ThemeConfig,

0 commit comments

Comments
 (0)