Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET 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 December 14th, 2004, 03:21 AM
Authorized User
 
Join Date: Aug 2003
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default Uninitialize a Variable?

Hi:

I've got a string array that's initialized and filled.
After I extract the values from it I want to 'uninitialize' it so that if the app tries to access it again an error occurs (which I capture in a catch().

So, How can I 'uninitialize' a variable once it's initialized?

__________________
http://www.softlinksys.com
Professional Software Developer since 1994.
 
Old December 15th, 2004, 01:12 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 326
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Santhi Send a message via MSN to Santhi
Default

Hi,
    Why u need to access the variable once it is unintialized??
If u want to unintialize the variable once it is intialized,then y u r intializing it.

 
Old December 15th, 2004, 03:04 AM
Authorized User
 
Join Date: Aug 2003
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I don't see what different it makes . . .

OK, I'll try to explain. The user can do a number of things. I maintain a list of fields for them using either a Request.Form field or a string Array. If I've used the string Array then the next time I need them, they will necessarily be from the Request.Form. To make sure I don't fill them from the Array instead I want to make sure it's 'dead'.

Really, it was a simple question.
Do you know the answer? Oh, I'm using C#.

 
Old December 15th, 2004, 12:25 PM
Authorized User
 
Join Date: Aug 2003
Posts: 18
Thanks: 0
Thanked 1 Time in 1 Post
Default

Not sure this addresses, not sure it works, but here are 2 possibilities. I'm not a C# programmer so this is pseudo code...

myArray= new Array

or

myArray =nothing
 
Old December 15th, 2004, 03:31 PM
Authorized User
 
Join Date: Aug 2003
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks.

I'm pretty sure Nothing doesn't work in C#.
In older VB I could never seem to use it as a check.
If oMyObj = Nothing Then <<-- never worked.

I might be able to just redimension the array like you suggest though.
Thanks

 
Old December 15th, 2004, 06:22 PM
Kep Kep is offline
Authorized User
 
Join Date: Aug 2003
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The equivalent of Nothing in C# is null.

myArray = null;

Kep.
 
Old December 15th, 2004, 06:28 PM
Authorized User
 
Join Date: Aug 2003
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I can't do that can I?
If I create a variable, say:
string MyString = "";

Then I say MyString = null;
it'll crash.






Similar Threads
Thread Thread Starter Forum Replies Last Post
ASSIGNING A JAVA SCRIPT VARIABLE TO A XSL VARIABLE SOMANATHAN10 XSLT 1 February 21st, 2007 04:26 AM
object variable or with block variable not set Aoude BOOK: Beginning VB.NET Databases 1 February 24th, 2006 05:21 PM
Object variable or With block variable not set tparrish Pro VB Databases 1 May 25th, 2005 02:08 PM
Object variable or With block variable not set tparrish Classic ASP Databases 0 May 21st, 2005 06:48 AM
Object variable or with block variable not set spacy ASP.NET 1.x and 2.0 Application Design 0 September 21st, 2004 12:19 AM





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