Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9213827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:50:21+00:00 2026-06-18T01:50:21+00:00

This is basically my first attempt to understand the classes in C#. I’ve went

  • 0

This is basically my first attempt to understand the classes in C#. I’ve went through several tutorials on the internet, but the thing I’m missing the most and what I haven’t found anywhere yet, is a simple good example.

I have some idea how my basic program should look like and I would appreciate your help:

using System;

namespace Introduction_to_classes
{
    class Person
    {
        int Age;
        string Name;

        int DateOfBirth()
        {
            return 2013 - Age;
        }
    }

    class Program
    {
        public static void Main()
        {
            Person Mother = new Person(35, Alice);
            Person Son = new Person(12, Johny);

            Mother.Name = "Lucy";  // Just changing the value afterwards

            if(Mother.Age > Son.Age)
            {
                int year = Mother.DateOfBirth();
                Console.WriteLine("Mom was born in {0}.", year);
            }

            Console.ReadLine();
        }
    }
}

It’s just an idea, it definitely doesn’t work. But more than anything else it would help me if you can correct it to the working example…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T01:50:22+00:00Added an answer on June 18, 2026 at 1:50 am
    class Person
    {
        public int Age { get; set; }
        public string Name { get; set; }
    
        public Person(int age, string name)
        {
            Age = age;
            Name = name;
        }
    
        public int DateOfBirth()
        {
            return 2013 - Age;
        }
    }
    
            class Program
            {
                public static void Main()
                {
                    Person Mother = new Person(35, "Alice");
                    Person Son = new Person(12, "Johny");
    
                    Mother.Name = "Lucy";  // Just changing the value afterwards
    
                    if (Mother.Age > Son.Age)
                    {
                        int year = Mother.DateOfBirth();
                        Console.WriteLine("Mom was born in {0}.", year);
                    }
                }
            }
    

    Some useful links: properties, constructor

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my first attempt at a plugin but I think I'm missing the
Hiya I am very new to C#, infact this is basically my first task
This is the first time I got this error. This code basically gets the
This is basically a math problem, but very programing related: if I have 1
This is basically a duplicate of this question , but the accepted answer was
Strange way to put a question, anyway ... Basically this is my first real
This is my first attempt at a php script after a few weeks of
This is my first attempt at updating a database using LINQtoSQL. At least, it's
I am trying to to build a Felix bundle in Eclipse. This basically includes
This code basically translates characters based on position in one string to the character

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.