docs
docs copied to clipboard
Program.cs(351,17): error CS0116: A namespace cannot directly contain…
… members such as field s, methods or statements ; Whats The Possible Solution Here.
using System;
namespace ConsoleApp6 { static void Main(string[] args) { int sum = 0; for (int number = 1; number < 21; number++) { if (number % 3 == 0) { sum = sum + number; } } Console.WriteLine($"The sum is {sum}"); } }
// In the video tutorial there is no problem in this code. But when i do the same code the error come out.
Summary
Describe your changes here.
Fixes #Issue_Number (if available)
This might just be a concern with not using top-level statements.
Hi @DebasisPaul
I think what's missing is the class. Here's the correct version:
namespace ConsoleApp6
{
public static class Program
{
static void Main(string[] args)
{
int sum = 0;
for (int number = 1; number < 21; number++)
{
if (number % 3 == 0)
{
sum = sum + number;
}
}
Console.WriteLine($"The sum is {sum}");}
}
}
I'll close this, as the PR is an unrelated whitespace change. I hope this info helps you finish the tutorial.