Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics 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 July 12th, 2003, 04:56 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default Passing by reference

How do I pass arguments by reference...!? I thought that it was default. I tried the following...
Code:
OCMSPage ocmsPage = null;
Distribute(pageType, ocmsPage);
if(ocmsPage != null) 
{
    ocmsPage.Make(pageID);
    Page.Controls.Add(ocmsPage);
}
Don't mind the type (OCMSPage). The method Distribute will do somthing like this (only piece of Distribute)...
Code:
oPage = (main_ascx) Page.LoadControl("controls/main.ascx");
oPage.ID = "ocmsPage";
And this has worked fine before I tried to put it into a seperate method, and works if I return the OCMSPage instead!

Thanks

Jacob.
__________________
Danish audio books for download at http://www.lytenbog.dk (Danske lydbøger til download).
 
Old July 12th, 2003, 05:07 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry! I found the answer myself, and if anybody is interested it goes like this in C#...

In the declaration of the method you shall add the keyword ref infront of the type, and when using the method you shall preceed the variable with the same keyword. The above becomes...

OCMSPage ocmsPage = null;
Distribute(pageType, ref ocmsPage);
if(ocmsPage != null)
{
    ocmsPage.Make(pageID);
    Page.Controls.Add(ocmsPage);
}

and further the prototype...

private void Distribute(int pageType, ref OCMSPage oPage)

Thanks anyway.

Jacob.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing by reference quiksilverhg Excel VBA 5 November 21st, 2005 03:49 AM
passing a const reference in C#.NET texasraven C# 2 December 21st, 2004 06:48 PM
Passing clas by reference ThunderBird Visual C++ 5 August 6th, 2004 06:26 AM
Passing a class by reference James Diamond VB How-To 13 February 16th, 2004 06:07 AM
Passing Reference Types by Value semiloof VS.NET 2002/2003 1 December 22nd, 2003 12:16 AM





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