Click here to Skip to main content
15,905,776 members
Home / Discussions / C#
   

C#

 
GeneralRe: using statement equivalent Pin
Not Active14-Jun-10 7:35
mentorNot Active14-Jun-10 7:35 
GeneralRe: using statement equivalent Pin
Al Beback14-Jun-10 6:04
Al Beback14-Jun-10 6:04 
AnswerRe: using statement equivalent PinPopular
harold aptroot14-Jun-10 6:01
harold aptroot14-Jun-10 6:01 
GeneralRe: using statement equivalent Pin
Eddy Vluggen14-Jun-10 6:06
professionalEddy Vluggen14-Jun-10 6:06 
GeneralRe: using statement equivalent Pin
harold aptroot14-Jun-10 6:12
harold aptroot14-Jun-10 6:12 
GeneralRe: using statement equivalent Pin
Al Beback14-Jun-10 6:18
Al Beback14-Jun-10 6:18 
Questiondatagrid in Compact Frame work Pin
jashimu14-Jun-10 4:49
jashimu14-Jun-10 4:49 
AnswerMessage Closed Pin
14-Jun-10 7:19
stancrm14-Jun-10 7:19 
GeneralRe: datagrid in Compact Frame work Pin
jashimu18-Jun-10 9:12
jashimu18-Jun-10 9:12 
QuestionFold all code in all of the project with one command Pin
Neo1010114-Jun-10 4:29
Neo1010114-Jun-10 4:29 
AnswerRe: Fold all code in all of the project with one command Pin
R. Giskard Reventlov14-Jun-10 4:58
R. Giskard Reventlov14-Jun-10 4:58 
GeneralRe: Fold all code in all of the project with one command Pin
Neo1010114-Jun-10 8:27
Neo1010114-Jun-10 8:27 
Questionthread and application response Pin
kasraa0009800014-Jun-10 4:29
kasraa0009800014-Jun-10 4:29 
AnswerRe: thread and application response Pin
Luc Pattyn14-Jun-10 4:35
sitebuilderLuc Pattyn14-Jun-10 4:35 
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 

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.