473,386 Members | 1,803 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,386 software developers and data experts.

Assigning value to an array inside a list?

Hello!

In my code, I've got a class called "teacher" which has some arrays inside of it:
Expand|Select|Wrap|Line Numbers
  1. public class teacher
  2.         {
  3.             //monday
  4.             public bool[] mon = new bool[11];
  5.  
  6.             //tuesday
  7.             public bool[] tue = new bool[11];
  8.  
  9.             //wednesday
  10.             public bool[] wed = new bool[11];
  11.  
  12.             //thursday
  13.             public bool[] thu = new bool[11];
  14.  
  15.             //fri
  16.             public bool[] fri = new bool[11];
  17.         };
There's also a list of the teachers:
Expand|Select|Wrap|Line Numbers
  1.         List<teacher> teachers = new List<teacher>();
Now, once I click a button that adds a teacher, I want those arrays to fill with the values of associated checkboxes, ie.

Expand|Select|Wrap|Line Numbers
  1. teachers.Add(new teacher
  2.             {
  3.                 mon[0] = checkBox25.Checked,
  4.                 mon[1] = checkBox26.Checked,
  5.                 mon[2] = checkBox27.Checked,
  6.             }
But it won't let me access mon[0], as it says "Invalid initializer member declarator". Any ideas on how to assign the value?

//EDIT
I've changed that last bit of code into
Expand|Select|Wrap|Line Numbers
  1. mon = {checkBox25.Checked, checkBox26.Checked, checkBox27.Checked, checkBox28.Checked, checkBox29.Checked, checkBox30.Checked, checkBox31.Checked, checkBox32.Checked, checkBox33.Checked, checkBox34.Checked, checkBox35.Checked},
but now it says that it cannot initialize object of type bool[] with a collection initializer.
Mar 9 '12 #1
0 1553

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: sathya | last post by:
I was going through an Boyer-Moore-Horspool pattern match, I saw a array inside a array, like the below, skip ] = patlen - i - 1; The array is decleared as int skip; unsigned char *pat;
2
by: Ananas | last post by:
Hi, Please give me an idea how to send a static array from dll written on C++ to C# application. This is a C++ code: const SIGNATURE_LENGTH = 50; struct Info {
1
by: sumitmishra | last post by:
HI FRIENDS i have a problem . i am trying to allocate array inside the for loop . Below is my code here int** character has been allocated inside the for loop and then i have used the delete...
3
by: johnmmcparland | last post by:
Hi all, I would like to have a static constant array inside a class definition which would contain the number of days in each month (I am writing a Date class as an exercise). However my...
6
by: zfareed | last post by:
<code> #include <iostream> #include <fstream> const int MAX_LENGTH = 10; using namespace std;
5
by: =?Utf-8?B?RWl0YW4=?= | last post by:
Hello, I am declaring an element like this: public static List<myListElementmyList = new List<myListElement>(); I would like to declare an array of this myList. How would I modify the...
8
by: getmeidea | last post by:
Hi, I am using JDK 1.5. I have a program like this. Here i am directly assigning value to one object. It does'nt give me any compile time or run time error. In java we dont have access to any...
10
by: J. Peng | last post by:
what's the difference between an array and a list in python? I see list has all features of array in C or perl. so please tell me.thanks.
10
by: Remus | last post by:
Greetings, My first time on this forum. I hope someone can help me out. I am trying to get 11 values from several different identically structured webpages. I have the list of webpages saved as...
3
by: raylopez99 | last post by:
This is an example of using multiple comparison criteria for IComparer/ Compare/CompareTo for List<and Array. Adapted from David Hayden's tutorial found on the net, but he used ArrayList so the...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
0
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...

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.