Hi,
I'm just wondering about the easiest way to copy certain values from a
collection to a simple array.
Say I've got a class (RaceCarDriver) with a DateFirstRace property. Now I'd
like to pass all DateFirstRace-Values in my RaceCarDriverCo llection to some
function as a DateTime[].
Any help is greatly appreceated.
--
kind regards,
matthias
--
I love deadlines. I like the whooshing sound they make as they fly by.
[Douglas Adams] 2 1446
Matthias,
In this case, you are going to have to create an array yourself, and
populate it. If you wanted to pass the RaceCarDriver array, then you could
just call CopyTo on the collection, and copy to that.
As a matter of fact, if you want, you could take the function that takes
a DateTime array, and have it take an array or collection of RaceCarDriver
instances, and then have the routine get the date time to perform it's
calculations.
I would actually supply both (one that takes DateTime, and another that
takes the collection or array). Factoring out the logic should be easy.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Matthias S." <matthias@_e_m_ v_o_i_d_.de> wrote in message
news:eT******** ******@TK2MSFTN GP12.phx.gbl... Hi,
I'm just wondering about the easiest way to copy certain values from a collection to a simple array.
Say I've got a class (RaceCarDriver) with a DateFirstRace property. Now I'd like to pass all DateFirstRace-Values in my RaceCarDriverCo llection to some function as a DateTime[].
Any help is greatly appreceated.
--
kind regards,
matthias
--
I love deadlines. I like the whooshing sound they make as they fly by. [Douglas Adams]
Hello Matthias,
You have to create a new DataTime array. Since the values are stored in
indivudual instances of the class RaceCarDriver you must enumerate the
entire collection to get the values.
the code would look like this:
// assumes drivers is RaceCarDriverCo llection
int id=0;
DateTime[] dates = new DateTime[drives.Count];
foreach (RaceCarDriver driver in drivers) {
dates[id++]=driver.DateFir stRace;
}
Michael
"Matthias S." <matthias@_e_m_ v_o_i_d_.de> wrote in message
news:eT******** ******@TK2MSFTN GP12.phx.gbl... Hi,
I'm just wondering about the easiest way to copy certain values from a collection to a simple array.
Say I've got a class (RaceCarDriver) with a DateFirstRace property. Now
I'd like to pass all DateFirstRace-Values in my RaceCarDriverCo llection to
some function as a DateTime[].
Any help is greatly appreceated.
--
kind regards,
matthias
--
I love deadlines. I like the whooshing sound they make as they fly by. [Douglas Adams]
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: booner |
last post by:
I have a form that when it loads I would like to highlight the values (from
a DB) that have been selected in a multiple selection list (<select
multiple="true">.
function onLoad()
{
document.forms.elements.value = "<value from
DB>";
}
|
by: domeceo |
last post by:
can anyone tell me why I cannot pass values in a setTimeout function
whenever I use this function it says "menu is undefined" after th
alert.
function imgOff(menu, num) {
if (document.images) {
document.images.src = eval("mt" +menu+ ".src")
}
alert("imgOff_hidemenu");
hideMenu=setTimeout('Hide(menu,num)',500);
|
by: Job Lot |
last post by:
How can i access all the values in a particular column of a DataTable.
How can i then store these values in an array.
|
by: simkn |
last post by:
Hello,
I'm writing a function that updates an array. That is, given an
array, change each element.
The trick is this: I can't change any elements until I've processed
the entire array. For example, the manner in which I update element 1
depends on several other (randomly numbered) elements in the array.
So, I can't change an element until I've figured out how every element
changes.
|
by: Richard Forester |
last post by:
Hello.
I need some help understanding what goes on when an array is copied. I
create 2 arrays and copy one to the other:
int pins = {9, 3, 7, 2};
int copy = new int;
for (int i = 0; i != copy.Length; i++)
| |
by: Sakharam Phapale |
last post by:
Hi All,
eg. "Array.Copy" method used to copy array elements.
Is there any method to copy collection objects data,
except iterating through original collection and then filling each element
into other collection, which is a lengthy process.
colBackupEmp = m_colEmp
Above statement sets the reference.
|
by: Daniel Mori |
last post by:
Hi, Im hoping someone can give me some advice.
Im doing some development using VS Whidbey 2005 beta 1.
Im about to implement some highly time critical code related to a
managed collection of floats.
I basically require the fastest way to convert a managed array of
floats into an unmanaged array of floats.
As far as the managed collection is implemented, ive read that the
|
by: Muskito |
last post by:
Hi,
Is it possible to copy the entire List(Of type) object to another
List(Of type) object
(they are both of the same type ofcourse) - without keeping the
reference?
There's the CopyTo method, but it only copies the data to a flat array.
I Need this for Backup in my program, when i update the master list and
|
by: Pukeko |
last post by:
Hi, this is an array that is used for a dropdown menu.
var imageArray = new Array(
"ecwp://" + document.location.host + "/massey/images/massey/
massey_07_fullres.ecw",
"ecwp://" + document.location.host + "/sampleiws/images/usa/
1metercalif.ecw",
"ecwp://" + document.location.host + "/sampleiws/images/australia/
parramatta.ecw";
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |