inaccessible due to protection level
-
I tried the following:
class MonthRec
{
string month_text;
string month_value;
}private void run_code()
{
List MonthList = new List();
MonthList.Add(new MonthRec(){month_text = "January 2009", month_value = "012009"});
}but getting month_text inaccessible due to protection level same error for month_value
-
I tried the following:
class MonthRec
{
string month_text;
string month_value;
}private void run_code()
{
List MonthList = new List();
MonthList.Add(new MonthRec(){month_text = "January 2009", month_value = "012009"});
}but getting month_text inaccessible due to protection level same error for month_value
By default if you don't specify an access modifier the scope of fields in a class default to private. Make both month_text and month_value public and you will be able to access them.
-
I tried the following:
class MonthRec
{
string month_text;
string month_value;
}private void run_code()
{
List MonthList = new List();
MonthList.Add(new MonthRec(){month_text = "January 2009", month_value = "012009"});
}but getting month_text inaccessible due to protection level same error for month_value
better yet, provide a constructor that accepts initial values and stores them. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
-
better yet, provide a constructor that accepts initial values and stores them. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
i did declare as public but now I am getting three columns! 1. Column with value myappname.myformname+MonthRec 2. month_value with no value 3. month_text with no value
-
i did declare as public but now I am getting three columns! 1. Column with value myappname.myformname+MonthRec 2. month_value with no value 3. month_text with no value
you should not make public what does not need to be public; my suggestion was and is keep the data members private (or protected) and provide a means to set them, either through properties or through a new constructor that takes initial values. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages