mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2025-12-19 10:07:46 -05:00
fix(curriculum): use C# highlighting in static typing discussion (#63890)
This commit is contained in:
@@ -40,8 +40,11 @@ const config = {
|
||||
{
|
||||
languages: [
|
||||
'bash',
|
||||
'c',
|
||||
'clike',
|
||||
'cpp',
|
||||
'css',
|
||||
'csharp',
|
||||
'html',
|
||||
'javascript',
|
||||
'json',
|
||||
|
||||
@@ -53,7 +53,11 @@ export function enhancePrismAccessibility(
|
||||
pug: 'pug',
|
||||
ts: 'TypeScript',
|
||||
typescript: 'TypeScript',
|
||||
tsx: 'TSX'
|
||||
tsx: 'TSX',
|
||||
csharp: 'C#',
|
||||
clike: 'CLike',
|
||||
c: 'C',
|
||||
cpp: 'C++'
|
||||
};
|
||||
const parent = prismEnv?.element?.parentElement;
|
||||
if (
|
||||
|
||||
@@ -20,15 +20,16 @@ In this example, we have a variable called `example` with the data type of strin
|
||||
|
||||
The flexibility of dynamic typing makes JavaScript more forgiving and easy to work with for quick scripting, but it can also introduce bugs that may be harder to catch, especially as your program grows larger.
|
||||
|
||||
In statically typed languages like Java or C++, you must declare the data type of a variable when you create it, and that type cannot change.
|
||||
In statically typed languages like C# or C++, you must declare the data type of a variable when you create it, and that type cannot
|
||||
change.
|
||||
|
||||
For instance, if you declare a variable as `integer`, you can only assign it integer values. If you try to assign it a different type, the program will throw an error.
|
||||
|
||||
Here's an example in Java language:
|
||||
Here's an example in C# language:
|
||||
|
||||
```java
|
||||
int value = 42; // value must always be an integer
|
||||
value = "Hello"; // This would cause an error in Java
|
||||
```csharp
|
||||
int data = 42; // data must always be an integer
|
||||
data = "Hello"; // This would cause an error in C#
|
||||
```
|
||||
|
||||
The difference between dynamic typing and static typing lies in the flexibility vs. the safety of your code. Dynamically typed languages offer flexibility but at the cost of potential runtime errors.
|
||||
|
||||
Reference in New Issue
Block a user