Click here to Skip to main content
15,887,350 members
Home / Discussions / C#
   

C#

 
Questiona bad control !!!! Pin
reza assar14-Jun-10 3:52
reza assar14-Jun-10 3:52 
AnswerRe: a bad control !!!! Pin
ostad_mrn14-Jun-10 4:24
ostad_mrn14-Jun-10 4:24 
QuestionUSB Reader Pin
S.Aijaz14-Jun-10 3:44
S.Aijaz14-Jun-10 3:44 
Answercross-post Pin
Luc Pattyn14-Jun-10 3:55
sitebuilderLuc Pattyn14-Jun-10 3:55 
QuestionDemo Deployment Pin
eraser95014-Jun-10 3:17
eraser95014-Jun-10 3:17 
AnswerRe: Demo Deployment Pin
Johnny J.14-Jun-10 3:36
professionalJohnny J.14-Jun-10 3:36 
AnswerRe: Demo Deployment Pin
kasraa0009800014-Jun-10 4:34
kasraa0009800014-Jun-10 4:34 
QuestionClass methods for accessing/modifying multiple array variables Pin
BenBJT14-Jun-10 2:59
BenBJT14-Jun-10 2:59 
Greetings,

I grew up learning C and Java, so having just recently taken to C# for a new project, I'm still find my way. Hopefully this isn't a silly question Smile | :)

Basically I wish to build a class that contains configuration info for my application. It needs to hold a port number, a directory/folder name, and 3 arrays: an array of booleans, an array of strings for descriptive names, and an array of integers. I've written get/set methods for the server port number and the array containing the booleans, but Visual Studio 2010 is giving me a compilation error with my get/set methods for the last two arrays. "Type '......' already defines a member called 'this' with the same parameter types". Yet if a try and explicitly set the get/set method for the specific array (without using 'this'), it does not work either.

Here is the code:

namespace Test
{
    public class TestConfig
    {
        private int ServerPort;
        private String folderName;

        private Boolean[] ChLog = new Boolean[12];
        private String[] Label = new String[12];
        private int[] CallibrationUnit = new int[12];


        //default constructor (omitted for clarity)


        //ServerPort number getter setter
        public int setServerPort
        {
            get
            {
                return ServerPort;
            }
            set
            {
                ServerPort = value;
            }
        }
        //this works fine
        public Boolean this[int pos]
        {
            get
            {
                return ChLog[pos];
            }
            set
            {
                ChLog[pos] = value;
            }
        }
        //this one is giving me the error
        public String this[int pos]
        {
            get
            {
                return Label[pos];
            }
            set
            {
                Label[pos] = value;
            }
        }
        //as is this one
        //I would have thought using "public int CallibrationUnit[int pos] instead  
        //would be possible, but this does not compile either
        public int this[int pos]
        {
            get
            {
                return CallibrationUnit[pos];
            }
            set
            {
                CallibrationUnit[pos] = value;
            }
        }
    }
}


Am I best to avoid using the get/set methods in this case? Or should I use a separate class for each of the arrays I'm trying to set up? (this seems very inefficient to me).
I've searched high and low for an example showing the interection of multiple array variables from within a class, but bizarrely I haven't found anything as complex is what I'm trying to do (and I don't think its that complicated).

Any feedback would be most appreciated.
Benjamin
AnswerRe: Class methods for accessing/modifying multiple array variables Pin
Łukasz Nowakowski14-Jun-10 3:15
Łukasz Nowakowski14-Jun-10 3:15 
AnswerRe: Class methods for accessing/modifying multiple array variables Pin
Luc Pattyn14-Jun-10 3:26
sitebuilderLuc Pattyn14-Jun-10 3:26 
Questionhow i know when user created Pin
noamtzu0014-Jun-10 2:47
noamtzu0014-Jun-10 2:47 
AnswerRe: how i know when user created Pin
Pete O'Hanlon14-Jun-10 3:36
mvePete O'Hanlon14-Jun-10 3:36 
GeneralRe: how i know when user created Pin
noamtzu0014-Jun-10 18:33
noamtzu0014-Jun-10 18:33 
QuestionGetting a column or parameter's data type from the database [modified] Pin
JohnLBevan14-Jun-10 1:42
professionalJohnLBevan14-Jun-10 1:42 
AnswerRe: Getting a column or parameter's data type from the database Pin
PIEBALDconsult14-Jun-10 2:44
mvePIEBALDconsult14-Jun-10 2:44 
GeneralRe: Getting a column or parameter's data type from the database Pin
JohnLBevan14-Jun-10 8:40
professionalJohnLBevan14-Jun-10 8:40 
GeneralRe: Getting a column or parameter's data type from the database Pin
PIEBALDconsult14-Jun-10 13:48
mvePIEBALDconsult14-Jun-10 13:48 
QuestionA few questions Pin
SRJ9214-Jun-10 1:12
SRJ9214-Jun-10 1:12 
AnswerRe: A few questions Pin
Eddy Vluggen14-Jun-10 2:08
professionalEddy Vluggen14-Jun-10 2:08 
GeneralRe: A few questions Pin
SRJ9214-Jun-10 10:08
SRJ9214-Jun-10 10:08 
GeneralRe: A few questions Pin
Eddy Vluggen14-Jun-10 10:38
professionalEddy Vluggen14-Jun-10 10:38 
QuestionLogin dialog on page loads Pin
Ramkithepower14-Jun-10 0:39
Ramkithepower14-Jun-10 0:39 
AnswerWrong forum - Try the ASP.NET forum. Pin
Pete O'Hanlon14-Jun-10 0:42
mvePete O'Hanlon14-Jun-10 0:42 
AnswerRe: Login dialog on page loads Pin
OriginalGriff14-Jun-10 0:43
mveOriginalGriff14-Jun-10 0:43 
AnswerRe: Login dialog on page loads Pin
Ramkithepower14-Jun-10 22:21
Ramkithepower14-Jun-10 22:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.