Solved

constructory tips and tricks

Posted on 2004-08-09
1
216 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
1 Comment
 
LVL 4

Accepted Solution

by:
NTAC earned 500 total points
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

728 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now