Visual Studio Development Bookmark and Share   
 index > Visual C# Express Edition > Strange Syntax Help
 

Strange Syntax Help

I'm new to C# and can write a simple interest calculator, but not without this before it. What is the breakdown of this syntax?

 

using System;
namespace CalculateInterestTable
{

    using System;
    public class Program
    {
        public static void Main(string[] args)
        {

 

 

 

ConradR.  Sunday, October 04, 2009 1:57 AM

Hello,

Your line that says "using System;" is out of place.
All "using" declarations should appear before any "namespace" declarations and code.

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
        }
    }
}


I have no context to phrase a response to your question.
It is obvious that there are many basics concepts that you do not understand.
In other words, most any reply might sound like a foreign language.

The method "Main" is the default entry point for C# programs.
Your are allowed to have only one entry point.  Period.
Your posted code snippet is incomplete and appears to be truncated.
I posted a complete snippet that should compile.

IF you wish a detailed explanation of what that stuff is, purchase a book on the language directed at beginners.


Rudedog  =8^D


Mark the best replies as answers. "Fooling computers since 1971."
Rudedog2  Sunday, October 04, 2009 2:47 PM
Hi,
Glad that you ask. Despite the Rudedog2 answer, please also visit MSDN Beginners Learning Center
http://msdn.microsoft.com/en-us/beginner/default.aspx
and
http://msdn.microsoft.com/en-us/beginner/bb964631.aspx

Plus I will second it's good to have some introductory level book on C#
such as
"Visual C# 2008 step by step" http://www.amazon.com/Microsoft-Visual-2008-Step/dp/0735624305
"Beginning C# 2008 from Novice to Professional" http://www.amazon.com/Beginning-2008-Novice-Professional-Second/dp/1430210338
"Head First C#" http://www.amazon.com/Head-First-C-Andrew-Stellman/dp/0596514824

If you have any query, please feel free to discuss further.

Thanks!


Adil Mughal - http://AdilMughal.com
Adil Mughal  Monday, October 05, 2009 10:50 AM

Hello,

Your line that says "using System;" is out of place.
All "using" declarations should appear before any "namespace" declarations and code.

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
        }
    }
}


I have no context to phrase a response to your question.
It is obvious that there are many basics concepts that you do not understand.
In other words, most any reply might sound like a foreign language.

The method "Main" is the default entry point for C# programs.
Your are allowed to have only one entry point.  Period.
Your posted code snippet is incomplete and appears to be truncated.
I posted a complete snippet that should compile.

IF you wish a detailed explanation of what that stuff is, purchase a book on the language directed at beginners.


Rudedog  =8^D


Mark the best replies as answers. "Fooling computers since 1971."
Rudedog2  Sunday, October 04, 2009 2:47 PM
Hi,
Glad that you ask. Despite the Rudedog2 answer, please also visit MSDN Beginners Learning Center
http://msdn.microsoft.com/en-us/beginner/default.aspx
and
http://msdn.microsoft.com/en-us/beginner/bb964631.aspx

Plus I will second it's good to have some introductory level book on C#
such as
"Visual C# 2008 step by step" http://www.amazon.com/Microsoft-Visual-2008-Step/dp/0735624305
"Beginning C# 2008 from Novice to Professional" http://www.amazon.com/Beginning-2008-Novice-Professional-Second/dp/1430210338
"Head First C#" http://www.amazon.com/Head-First-C-Andrew-Stellman/dp/0596514824

If you have any query, please feel free to discuss further.

Thanks!


Adil Mughal - http://AdilMughal.com
Adil Mughal  Monday, October 05, 2009 10:50 AM

Your line that says "using System;" is out of place.
All "using" declarations should appear before any "namespace" declarations and code.

Actually, it is not a syntax error to place a using directive inside a namespace body. It is very uncommon but not a syntax error.

For example the following code does compile without problems

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    using System.Diagnostics;

    class Program
    {
        static void Main(string[] args)
        {
        }
    }
}


bassem.qsh.eu
Bassem.mf  Tuesday, October 06, 2009 1:04 PM
You are correct on one point.  It is a valid syntax.

No one called it a syntax error, but I did declare it as "out of place".  It is redundant, too.
Let's not confuse someone who apparently discovered C#---and maybe even any sort of programming---just yesterday.

The original code snippet appears to be incomplete, or otherwise truncated. 
The code would not compile without additional stuff.
I left it at that until the OP replies.
Mark the best replies as answers. "Fooling computers since 1971."
Rudedog2  Tuesday, October 06, 2009 1:15 PM

You can use google to search for other answers

Custom Search

More Threads

• NotifyIcon problem
• Is there a kind of union structure in C Sharp?
• Help a dude out...please
• How do I make windows controls maximize when the Form is maximized?
• C# Service Pack problems
• what did I miss in com interop?
• How do I Add a Property (field) at runtime in C#
• Idea For A Security System
• VC# Express 2008 and WWF
• Implements Different to VB