0

Hi guys, can some one help to see what is problem with below code. I am newbie to C#:
Thanks

=================================================================================

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

namespace Lesson4Inheritance2
{
    class Student
    {

       public static void Main(string[] args)
        {
       
            private int registrationNumber;
            private string name;
            private DateTime DateOfBirth;

            public Student()
            {
                Console.WriteLine("New Student created. Parameterless constructor called....");
            }
        }
    }
}

Edited by __avd: Added [code] tags. Do wrap your programming code blocks within [code] ... [/code] tags

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by mano100
1

Your constructor and class fields are nested inside Main. It should look like this:

class Student
{
    private int registrationNumber;
    private string name;
    private DateTime DateOfBirth;

    public Student()
    {
        Console.WriteLine("New Student created. Parameterless constructor called....");
    }

    public static void Main(string[] args)
    {
    }
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.