Solved

constructory tips and tricks

Posted on 2004-08-09
1
230 Views
Last Modified: 2010-04-15
Say i Have 4 constructors in the same class,  all of them have different parms (of course)

but they all have to call the same setUp method called tis._setPropertyInfo

Is there a way to kind of build on the work that is being done by one constructor to do the next?

so that I can just call or use the base Constructor each time?
0
Comment
Question by:jayrod
[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
1 Comment
 
LVL 4

Accepted Solution

by:
NTAC earned 500 total points
ID: 11756816
If they are all calling the same setup method--just place the common code in that method.  

If you want--you can call one constructor from another like this:

public class Class1
{
   private string s;

    public Class1(): this("Hello")
    {

    }

    publicClass1(string test)
    {
        s = test;

    }
}

This link gives more info, as well as the C# documentation
http://www.codeproject.com/dotnet/ConstructorsInCSharp.asp
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

615 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