search
Japanese Chinese Nederlands Espanol Italiano Deutsch Francais Twitter Rss Feeds
.NET Framework GroupsView
Deployment Server
.NET Distributed_Apps
.NET
.NET ADO.NET
.NET ASP.NET
.NET ASP.NET Security
.NET ASP.NET Webcontrols
.NET ASP.NET Web Services
.NET Clr
.NET Compact Framework
.NET Drawing
.NET Interop
.NET Micro Porting
.NET Performance
.NET Web Services
.NET Windows Forms
.NET Windows Forms Controls
.NET General
.NET Csharp
.NET Visual Basic
.NET Vc
.NET Security
.NET Xml
Scripting Jscript
Scripting Visual Basicscript
Scripting Wsh
Smartphone Developer
Visual Basic Com
Visual Basic Controls
Visual Basic Crystal
Visual Basic Database Ado
Visual Basic Syntax
Visual Basic Vista Compatibility
Visual Basic Winapi
Vc Atl
Vc Debugger
Vc Language
Vc Mfc
Vc Stl
Visio Developer Visual Basica
Vsnet Debugging
Windows Powershell
Windowsce Embedded Vc
Xml
Xsl

Group SummariesView
.NET Framework
Access
BizTalk
Certifications
CRM
DDK
Exchange Server
FoxPro
French
French .NET
Games
German
German .NET
Graphic Design
IIS
Internet
ISA Server
Italian
Italian .NET
Maps
MCIS
Miscellaneous
Mobile Application Development
Money
MSN
Networking
Office
Ops Mgr
Publisher
Security
SharePoint
Small Business
Spanish
Spanish .NET
SQL Server
Systems Management Server
Transaction Server
Virtual PC / Virtual Server
Visual Studio
Win32
Windows 2000
Windows 2003 Server
Windows 7
Windows Live
Windows Media
Windows Update
Windows Vista
Windows XP
 

View All Microsoft NET Csharp Posts  Ask A New Question 

array manipulations - rodcha

Friday, February 22, 2008 10:53 PM

hey all,
Label[] lbls = {Label1, Label2, Label3};

i know you can iterate thru the elements, cast to Label object, and then set
its visibility. But is there a way to set the elements all at once without
loop structures?
just wondering.

thanks,
rodchar
reply
 

array manipulations - Peter Duniho

Friday, February 22, 2008 11:12 PM

On Fri, 22 Feb 2008 19:53:01 -0800, rodchar  =


en  =


Just to be clear: if you have an array declared as Label[], there is no =
=

need to cast any element to a Label.  Retrieving an element from the arr=
ay  =

gives you something that's already a Label type.


Do you mean "set the visibility of each element"?  That is, set  =

Label.Visible to "true" for each element?  Or otherwise perform some  =

specific operation on each element?

If so, then no.  Somewhere, something needs to loop on the elements.

However, there are of course ways to write code such that this looping i=
s  =

done implicitly.  For example, you could use the Array.ForEach() method,=
=

which takes as a parameter a method to call for each element.  You can  =

provide a method that sets the Visible property, and the ForEach() metho=
d  =

will call that other method repeatedly, once for each element in the arr=
ay.

Pete
reply

array manipulations - rodcha

Saturday, February 23, 2008 12:00 AM

thank you for the insight pete,
rod.
reply

Previous Microsoft NET Csharp conversation.