Wrox Programmer Forums
.NET Framework 2.0 For discussion of the Microsoft .NET Framework 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Framework 2.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old September 18th, 2008, 04:59 AM
Registered User
Join Date: Dec 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Constructor and reference question


I have two questions.

1. Is it possible to call base constructor in the body of the current constructor?
I want code like this:

class MyClass
    public MyClass()
        // some code here

2. I don't understand this code. I have an object that returns reference to the DataTable it contains. I am wondering how come that in following code t variable remains valid:

void MyClass()
    DataTable t;

    void SomeFunc(){
       using ( ObjectWithTable owt = new ObjectWithTable() )
            t = owt.Table;


The GC will free the owt as soon as it exits the using statement, but I can still access its table over t.


Similar Threads
Thread Thread Starter Forum Replies Last Post
Returning Nothing from a constructor Imar Pro VB.NET 2002/2003 8 June 29th, 2012 02:00 PM
Constructor nayeem69 .NET Framework 2.0 1 July 17th, 2007 12:33 AM
Constructor ramess C++ Programming 1 March 18th, 2006 07:23 PM
constructor in servlets bondalapati98 Servlets 5 January 16th, 2006 12:27 AM
VB constructor snowbelly VB How-To 2 August 18th, 2004 04:42 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.