Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Csharp commentss #5466

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 31 additions & 19 deletions content/c-sharp/concepts/comments/comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,34 @@ CatalogContent:

A **comment** is a piece of text within a program that is not executed. It can be used to provide additional information to aid in understanding the code.

### Single-line Comments
## Why Use Comments?

For single-line comments, the compiler ignores any text after two consecutive forward slashes (`//`) on the same line.
1. **Documentation**: Help document what specific parts of the code do, making it easier for others (or yourself) to understand when revisiting the code later.
2. **Debugging**: Temporarily disable code without removing it, making debugging easier.
3. **Clarity**: Improve the readability of the code, especially in complex sections.

```cs
// Comment goes here
executing code // Comment goes here
```
## Single-line Comments

### Multi-line Comments
A **single-line comment** is a comment that occupies a single line. It starts with two forward slashes (`//`), and everything after those slashes on that line is ignored by the compiler.

Multi-line comments begin with `/*` and end with `*/`. The compiler ignores any text in between.
### Example

```cs
/*
This is all commented out.
None of it is going to run!
*/
// This is a single-line comment
Console.WriteLine("This code will execute."); // Inline comment explaining the code

```

### Example
### Multi-line Comments

The following examples show various comment styles:
A **multi-line comment** is used for comments that span multiple lines. It begins with `/*` and ends with `*/`. The compiler ignores everything in between.

```cs
// This line will denote a comment in C-sharp.
Console.WriteLine("Hello World!"); // This is a comment.
/*
This is a multi-line
comment.
This is a multi-line comment.
It can span multiple lines.
*/
Console.WriteLine("This code will also execute.");
```

### XML Comments
Expand All @@ -57,7 +54,9 @@ comment.
The following is a single-line XML comment, which uses three forward slashes (`///`):

```cs
/// XML Comment goes here
/**
XML Comments go here
*/
```

Multi-line XML comments are similar to regular multi-line comments, except that an extra asterisk `*` is used in the opening:
Expand All @@ -78,3 +77,16 @@ XML tags embedded in XML comments are used to signal a specific functionality of
/// </summary>
public class MyClass {}
```

```cs
// Another XML comment example
/// <summary>
/// This method calculates the sum of two integers.
/// </summary>
/// <param name="a">The first integer</param>
/// <param name="b">The second integer</param>
/// <returns>The sum of a and b</returns>
public int Add(int a, int b) {
return a + b;
}
```
16 changes: 6 additions & 10 deletions content/javascript/concepts/modules/modules.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
Title: 'Modules'
Description: 'As the program grows bigger, it may contain many lines of code. Instead of putting everything in a single file, modules can be used to separate codes in separate files as per their functionality. This makes the code more organized and easier to maintain. A module is a file that contains code that performs a specific task. A module may contain variables, functions, classes, etc. Suppose, a file named greetPerson.js contains the following code: js // Exporting a function export function greetPerson(name) { return Hi, ${name};'
Description: 'Modules help keep code organized by putting related code, like functions, classes, and variables, into separate files. This makes it easier to manage and reuse in larger projects.'
Subjects:
- 'Web Development'
- 'Computer Science'
Expand All @@ -11,11 +11,9 @@ CatalogContent:
- 'paths/front-end-engineer-career-path'
---

As the program grows bigger, it may contain many lines of code. Instead of putting everything in a single file, modules can be used to separate codes in separate files as per their functionality. This makes the code more organized and easier to maintain.
Modules split large programs into separate files based on tasks, containing related functions, variables, or classes for easier management and reuse.

A module is a file that contains code that performs a specific task. A module may contain variables, functions, classes, etc.

Suppose, a file named **greetPerson.js** contains the following code:
Suppose a file named **greetPerson.js** contains the following code:

```js
// Exporting a function
Expand Down Expand Up @@ -87,9 +85,7 @@ Here, both the `name` variable and the `difference()` function from the **module

## Renaming Imports and Exports

If the objects (variables, functions, etc.) that you want to import are already present in your main file, the program may not behave as you want. In this case, the program takes value from the main file instead of the imported file.

To avoid naming conflicts, you can rename these objects during the export or during the import.
To prevent naming conflicts, rename variables or functions when exporting or importing. This ensures the program uses the correct values from the intended file.

### Rename in the export file (the module)

Expand All @@ -103,7 +99,7 @@ export { function1 as newName1, function2 as newName2 };
import { newName1, newName2 } from './module.js';
```

Here, while exporting the function from **module.js** file, new names (here, `newName1` & `newName2`) are given to the function. Hence, when importing that function, the new name is used to reference that function.
When exporting from module.js, new names (newName1, newName2) are assigned to functions. The new names must be used when importing and referencing them.

### Rename in the import file (the main file)

Expand All @@ -117,7 +113,7 @@ export { function1, function2 };
import { function1 as newName1, function2 as newName2 } from './module.js';
```

Here, while importing the function, the new names (here, `newName1` & `newName2`) are used for the function name. Now you use the new names to reference these functions.
When importing the function, new names (`newName1`, `newName2`) are used. These new names are then used to reference the functions in the code.

## Default Export

Expand Down
Loading