Expanded upon guideline info
- Fixed scope example to be wrapped in a class. Aside from that, it's solid.
This commit is contained in:
parent
252db96518
commit
c5960f9f6c
1 changed files with 17 additions and 11 deletions
|
@ -1,6 +1,8 @@
|
||||||
# NASA-style Programming for C#
|
# NASA-style Programming for C#
|
||||||
|
|
||||||
I asked the AI to write their instructions in the form of guidelines. I figured I'd use C# since it's both my preferred language and the syntax should be fairly easy to grasp once you understand the basics. My only request was to apply .NET 6's [top-level statements](https://learn.microsoft.com/en-us/dotnet/csharp/tutorials/top-level-statements) for brevity. Aside from that, it all works flawlessly.
|
I asked the AI to write their instructions in the form of guidelines. I figured I'd use C# since it's both my preferred language and the syntax should be fairly easy to grasp once you understand the basics.
|
||||||
|
|
||||||
|
My only request was to apply .NET 6's [top-level statements](https://learn.microsoft.com/en-us/dotnet/csharp/tutorials/top-level-statements) for brevity. Aside from a few organizational tweaks with the guidelines and fixing the scope example to be wrapped in a class, it all works flawlessly.
|
||||||
|
|
||||||
## 1. Write Clear, Well-Structured, and Maintainable Code
|
## 1. Write Clear, Well-Structured, and Maintainable Code
|
||||||
|
|
||||||
|
@ -88,18 +90,22 @@ using (var reader = new StreamReader("example.txt"))
|
||||||
**Example:**
|
**Example:**
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
void Main()
|
namespace Application;
|
||||||
{
|
|
||||||
int a = 5, b = 3;
|
|
||||||
Console.WriteLine($"Sum: {Add(a, b)}");
|
|
||||||
|
|
||||||
// 'a' and 'b' are limited to Main method scope
|
class Program
|
||||||
}
|
|
||||||
|
|
||||||
int Add(int a, int b)
|
|
||||||
{
|
{
|
||||||
// 'a' and 'b' are limited to Add method scope
|
static void Main()
|
||||||
return a + b;
|
{
|
||||||
|
// 'a' and 'b' are limited to Main method scope
|
||||||
|
int a = 5, b = 3;
|
||||||
|
Console.WriteLine($"Sum: {Add(a, b)}");
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Add(int a, int b)
|
||||||
|
{
|
||||||
|
// 'a' and 'b' are limited to Add method scope
|
||||||
|
return a + b;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue