473,388 Members | 1,335 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

array manipulations

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
Feb 23 '08 #1
2 1219
On Fri, 22 Feb 2008 19:53:01 -0800, rodchar
<ro*****@discussions.microsoft.comwrote:
hey all,
Label[] lbls = {Label1, Label2, Label3};

i know you can iterate thru the elements, cast to Label object, and then
set
its visibility.
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 array
gives you something that's already a Label type.
But is there a way to set the elements all at once without
loop structures?
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 is
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() method
will call that other method repeatedly, once for each element in the array.

Pete
Feb 23 '08 #2
thank you for the insight pete,
rod.

"Peter Duniho" wrote:
On Fri, 22 Feb 2008 19:53:01 -0800, rodchar
<ro*****@discussions.microsoft.comwrote:
hey all,
Label[] lbls = {Label1, Label2, Label3};

i know you can iterate thru the elements, cast to Label object, and then
set
its visibility.

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 array
gives you something that's already a Label type.
But is there a way to set the elements all at once without
loop structures?

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 is
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() method
will call that other method repeatedly, once for each element in the array.

Pete
Feb 23 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Håvard Olerud Eriksen | last post by:
I've been working on a webshop, and I've got most of the functionality up and running. One problem, however, that I don't seem to be able to solve is as follows. My shopping cart is stored in...
4
by: J. Campbell | last post by:
I'm a novice with c/c++ and have been reading Eckel's book. I'd like some feedback on using this method. What I need to do is treat a string as numeric data. I know how to write functions to...
8
by: Marco | last post by:
Hi all, I have a base class and some subclasses; I need to define an array of objects from these various subclasses. What I have is something like: { //I have a base class, something like:...
20
by: Someonekicked | last post by:
im trying to declare a two dimensional array using pointers. but it is not working, any ideas?
19
by: David | last post by:
Hi all, A while back I asked how to sort an array of strings which would have numerals and I wanted to put them in sequential numerical order. For example: myArray = "file1"; myArray =...
272
by: Peter Olcott | last post by:
http://groups.google.com/group/comp.lang.c++/msg/a9092f0f6c9bf13a I think that the operator() member function does not work correctly, does anyone else know how to make a template for making two...
6
by: craig.keightley | last post by:
i have the following array: Array ( =Array ( =Leamore Windows Ltd =553398833511417 =20 )
2
by: Rob111b | last post by:
Hi there, I need to make a piece of code in C that 1. opens a specified file, 2. Reads the data in the file and separates it as shown below, 3. Converts the strings into integers and then...
3
by: Sean Davis | last post by:
I have a set of numpy arrays which I would like to save to a gzip file. Here is an example without gzip: b=numpy.ones(1000000,dtype=numpy.uint8) a=numpy.zeros(1000000,dtype=numpy.uint8) fd =...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.