Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

constructory tips and tricks

Posted on 2004-08-09
1
Medium Priority
?
234 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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

715 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