?
Solved

C# oop Basics

Posted on 2012-04-06
3
Medium Priority
?
447 Views
Last Modified: 2012-04-06
Hello,

i new to c# and programming i have to create something like this:



users user01  = new users("bob", "Piet");   //if no date given it should be set to 2012
users user02  = new users("Roels", "Lut",2003);
users user03  = new users("Adams", "Tom",1989);
users user04  = new users("Dhondt", "Leen",1985);


But i dont knwo how to do this , my class looks like this :
using System;

namespace ConsAppl1TI11
{
    class users 
    {
        public users (string Naam, string voornaam, int jaar)
        {

        }
        public users ()
        {

        }
    }
}

Open in new window


i have to give 3 arguments
0
Comment
Question by:kensy11
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 70

Assisted Solution

by:Éric Moreau
Éric Moreau earned 664 total points
ID: 37815813
Homeworks?

you will need another constructor with only 2 arguments that will call the existing one passing 2012 for the last value.
0
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 668 total points
ID: 37815899
If you are using C# 4.0 (essentially Visual Studio 2010 or better), then you can have a default value for the parameter:

public users (string Naam, string voornaam, int jaar = 2012)
{

}

Open in new window

0
 
LVL 23

Accepted Solution

by:
wdosanjos earned 668 total points
ID: 37815954
In case you need the default value to be the current year instead of a constant.
using System;

namespace ConsAppl1TI11
{
    class users 
    {
        public users (string Naam, string voornaam, int jaar)
        {

        }
        public users (string Naam, string voornaam) : this(Naam, voornaam, DateTime.Now.Year)
        {

        }
        public users ()
        {

        }
    }
}

Open in new window

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month11 days, 16 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question