I have a problem with trying to instantiate an array of object types from a class that I have made. I am doing this becuase I want to easily access their data members from their array all at once such as: Address[0].Zip, Address[1].Zip, Address[3].Zip, ect. My problem is that when I made an object array to hold them in, they don't show up once I use the dot operator in the Intellisense, so it makes me feel as if I am doing something wrong: -
//object array to hold each address
-
object[] test = new object[10];
-
-
//I know hard coding this is not the best option, but I
-
//wanted to make sure this wasn't where I was messing up at
-
test[0] = new Address("Oak Chase Dr", "Tucker", "Georgia", 30041);
-
test[1] = new Address("Oak Chase Dr", "Decatur", "Georgia", 30042);
-
test[2] = new Address("Oak Chase Dr", "Atlanta", "Georgia", 30040);
-
test[3] = new Address("Oak Chase Dr", "Decatur", "Georgia", 30044);
-
test[4] = new Address("Oak Chase Dr", "Tucker", "Georgia", 30084);
-
test[5] = new Address("Oak Chase Dr", "Atlanta", "Georgia", 30040);
-
test[6] = new Address("Oak Chase Dr", "Atlanta", "Georgia", 30040);
-
test[7] = new Address("Oak Chase Dr", "Decatur", "Georgia", 30038);
-
test[8] = new Address("Oak Chase Dr", "Tucker", "Georgia", 30039);
-
test[9] = new Address("Oak Chase Dr", "Atlanta", "Georgia", 30040);
-
-
//will hold address with same Zip
-
List<Address> Addresses = new List<Address>();
-
-
-
for (int i = 0; i < address.Length ; i++)
-
{
-
//here's problem 1, cannot find "address[i].Zip"
-
if (address[i].Zip == 30040)
-
{
-
//problem 2,
-
Addresses.Add(address[i]);
-
}
-
i++;
-
}
-
-
public class Address
-
{
-
//properties
-
public string StreetName;
-
public string City;
-
public string State;
-
public int Zip;
-
-
//consructor
-
public Address(string StreetName, string City, string State, int Zip)
-
{
-
StreetName = "Street";
-
City = "City";
-
State = "State";
-
Zip = 00000;
-
}
-
-
//destructor
-
~Address() { }
-
}
-
-
1 1596 Rabbit 12,516
Recognized Expert Moderator MVP
Your array is called addresses not address.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Leigh Riley |
last post by:
Hi,
Can someone tell me if the following is possible?
I have a file containing some STATIC variables, and some functions e.g.
-------------------------------------------------
$ARCHIVE_INPUT_FILES = false;
$ARCHIVE_OUTPUT_FILES = false;
$ARCHIVE_CONFIG_FILES = false;
$HTML_BODY_BACKGROUND = "gfx/gradient.gif";
|
by: Jo Schambach |
last post by:
I want to build an array of entry widgets in python with Tkinter that
all have similar textvariables. I was hoping that I could use an array
of StringVar variables to attach to these widgets, so that I can loop
through the widget creation. But my simple minded approach failed:
for i in range(32):
self.dllAdjust = StringVar()
self.dllAdjust.set('000')
gives me the following error:
|
by: Jim Heavey |
last post by:
Hello, I have created a form which I intend to use a a dialog box. It has
a few controls on that form and I changed the properties of those controls
to "public" with the idea that I could access those controls from the
"calling form", but I am unable to access/see those controls. Why?
Here are portions of my code
Here I am substantiating the new form and trying to set values for the
controls on that form...
|
by: Raphael Iloh |
last post by:
Hi all, I'm having problems comparing array objects. Take a look at this:
int array1 = new int{1};
int array2 = new int{1};
Console.Writeln(array1.Equals(array2));
One would expect the above expression to return true as both arrays are
identically the same but it keeps returning false. Any info on how to solve
this problem will be appreciated.
|
by: Steve |
last post by:
this code:
private Array m_arrays = new Array;
results in an array of 3 null Array objects. What am I missing?
| |
by: active |
last post by:
Because of an example I followed I've been instantiating Image objects. Now
I notice that the documentation says the Image class is an abstract base
class.
Things seem to be working! Is the documentation wrong (it also says abstract
classes cannot be instantiated)?
Should I be using Bitmap instead?
Is there a difference between Abstract class and Abstract base class?
|
by: Nathan |
last post by:
Hi,
I have created a class library creating a number of forms and a few public
variables. I have a project that references the .dll for this class
library, and in that project I need to access those public variables.
For instance, the main app calls a form in the referenced library, that form
changes the value of PublicVar1 and then closes. The main app now needs to
know the value of PublicVar1.
|
by: Jurek Dabrowski |
last post by:
hi all,
I have a question in reference to accessing variables in another class maybe
someone has dealt with before.
I have some public variables declared in my main plug-in class
CCommandMeshToSrf,
eg: BOOL m_bHaveAnswer;
I want to set this variable from within a dialog class which is defined in
separate .h and .cpp files of course. How would one access this varibale
from a method defined in my CTestModelessDialog class ?
|
by: Ispep |
last post by:
Hi, unfortunately having a bit of difficulty with a question from an Open University course I'm currently doing. If you could help me out in any way I'd be grafeul (though obviously it goes without saying I'm not asking you to solve the question - that won't help come exam time :().
Anyway I have a CSV delimited file in the following format;
STRING,INT
STRING,INT,INT,INT,INT,INT
STRING,INT,INT,INT,INT,INT
STRING,INT,INT,INT,INT,INT
...
|
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: 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...
|
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,...
|
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: 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: 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...
| |