473,805 Members | 2,074 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with - Edit Item of Collections.Gen eric.List(Of SearchAreaListI tem)

I have a structure called SearchAreaListI tem.

The structure has some properties.

The application implements this as a collection.gene ric.list(of SearchAreaListI tem)

I load the collection up item at a time stuffing values into the item then adding the item to the
collection.
Now here come the rub.

There is one property attached to SearchAreaListI tem, that I need to CHANGE so we can track whether the item has been accessed.

However when I try the following;
STEP 1: Dim SearchAreaList as new collection.gene ric.list(of SearchAreaListI tem)

STEP 2: Call function to load each item and add to collection

STEP 3: Try to set the Accessed property on Item X

SearchAreaList. Item(x).Accesse d = True

STEP 3 is not acceptable to Visual Studio and I get the design time error

Error 1 Expression is a value and therefore cannot be the target of an assignment.

Why can't I set a property of a structure through an index of a collection.gene ric.list(of SearchAreaListI tem)??
Mar 27 '06 #1
3 5547
Why can't I set a property of a structure through an index of a collection.gene ric.list(of SearchAreaListI tem)??


Becuase a structure givs you a value type, and therefore the List
indexer returns a copy of the instance. Even if the compiler let you
do what you want, you would modify the temporary copy, not the one in
the list. The solution is to use a class (a reference type) instead.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Mar 27 '06 #2
snesbit,

In order to do what you want, SearchAreaListI tem needs to be a class, not a
structure.

Kerry Moorman
"snesbit" wrote:
I have a structure called SearchAreaListI tem.

The structure has some properties.

The application implements this as a collection.gene ric.list(of SearchAreaListI tem)

I load the collection up item at a time stuffing values into the item then adding the item to the
collection.
Now here come the rub.

There is one property attached to SearchAreaListI tem, that I need to CHANGE so we can track whether the item has been accessed.

However when I try the following;
STEP 1: Dim SearchAreaList as new collection.gene ric.list(of SearchAreaListI tem)

STEP 2: Call function to load each item and add to collection

STEP 3: Try to set the Accessed property on Item X

SearchAreaList. Item(x).Accesse d = True

STEP 3 is not acceptable to Visual Studio and I get the design time error

Error 1 Expression is a value and therefore cannot be the target of an assignment.

Why can't I set a property of a structure through an index of a collection.gene ric.list(of SearchAreaListI tem)??

Mar 27 '06 #3
Snesbit,

It sounds for me so crazy

A generic list of a value that is placed on the stack

Cor
"snesbit" <sn*****@portal tech.com> schreef in bericht news:Oe******** ******@TK2MSFTN GP09.phx.gbl...
I have a structure called SearchAreaListI tem.

The structure has some properties.

The application implements this as a collection.gene ric.list(of SearchAreaListI tem)

I load the collection up item at a time stuffing values into the item then adding the item to the
collection.
Now here come the rub.

There is one property attached to SearchAreaListI tem, that I need to CHANGE so we can track whether the item has been accessed.

However when I try the following;
STEP 1: Dim SearchAreaList as new collection.gene ric.list(of SearchAreaListI tem)

STEP 2: Call function to load each item and add to collection

STEP 3: Try to set the Accessed property on Item X

SearchAreaList. Item(x).Accesse d = True

STEP 3 is not acceptable to Visual Studio and I get the design time error

Error 1 Expression is a value and therefore cannot be the target of an assignment.

Why can't I set a property of a structure through an index of a collection.gene ric.list(of SearchAreaListI tem)??
Mar 28 '06 #4

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

Similar topics

1
6247
by: Roger | last post by:
I need to edit the IIS 6.0 config file (metabase.xml) and had a go with this code, trying to get a list of all defined websites, and write their name to console, but it does not seem to work, would appreciate any pointers: ----------- Try Dim doc As New XmlDocument Dim nodelist As XmlNodeList Dim node As XmlNode
1
1150
by: jonathan | last post by:
Hi I have a class that contains an array of another class: public abstract class Node {} public class elem1 : Node { public ArrayList NodeItems1=new ArrayList (); }
3
967
by: Crirus | last post by:
Where can I find such a list of all types (classes) that are collections of another types..arrays included -- Ceers, Crirus ------------------------------ If work were a good thing, the boss would take it all from you
1
1507
by: Allen Maki | last post by:
Why can I get the index of the item of the array when I use string*, but can not get the index of the array when I use any other type (such as Int32)? This code will compile perfectly, but if I replace String* with Int32, the code would not compile? The code using String* type: #include "stdafx.h"
6
2265
by: Dasn | last post by:
Hi, there. 'lines' is a large list of strings each of which is seperated by '\t' I wanna split each string into a list. For speed, using map() instead of 'for' loop. 'map(str.split, lines)' works fine , but... when I was trying: I got "TypeError: 'list' object is not callable".
38
1820
by: Rex | last post by:
In a table, I have number of records belonging to a particular ID now if I enter a value in one of the fileds of this table I want it to be copied in all the records belonging to this particluar ID. for example ID Name -------------------------- 1 xyz 1 1 1
28
1615
by: walterbyrd | last post by:
Python seems to have a log of ways to do collections of arbitrary objects: lists, tuples, dictionaries. But what if I want a collection of non-arbitrary objects? A list of records, or something like that?
4
11438
by: shapper | last post by:
Hello, I am getting various records from a database: Dim ds As DataSet = db.ExecuteDataSet(dbc) Each record has 3 fields: Id, Name and Text. I have a class named MyClass with 3 properties Id, Name and Text.
11
1582
by: Louis.Soninhu | last post by:
Hi pals I have a list like this mylist= I'd like to remove the first and the last item as they are irrevalent, and convert it to the dict: {'tom':'boss','mike':'manager','paul':'employee'}
0
9596
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,...
0
10613
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10363
jinu1996
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...
1
10368
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10107
tracyyun
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...
1
7649
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4327
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
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.