TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
David Schofield
NA
1
835
code out certain lines
Feb 10 2016 9:36 AM
In C# I know about adding comments like // , /* , */
I have a code which allows a number of i2C devices to run, if I remove a device the program stops. I have been trying to find a way to comment out multiple lines in various areas of the code to allow me to select the number of devices. As it is I have to edit the code directly by adding or taking away comments.
Ideally I want to be able to simply choose a number of devices to for example 2 and the code will ignore the relevant lines.
Anyone any have pointers or ideas as I am new to C# thank you.
Would adding a variable line like :-
var numberofMCP23017 = omit lineNumber
omit { lineNumber = 1, omit lines, 27 TO 103 + 105 TO 109 + 119 TO 126 + 164 TO 196 + 226 TO 336 + 379 TO 480 + 503 TO 580 }
Below is some of the code and I have added instructions for commenting.
// TO CHANGE THE NUMBER OF MCP23017's THAT YOU USE PUT /* IN FRONT */ at end OF FOLLOWING LINES
// FOR ONE 27 TO 103 + 105 TO 109 + 119 TO 126 + 164 TO 196 + 226 TO 336 + 379 TO 480 + 503 TO 580
// FOR TWO 46 TO 103 + 106 TO 109 + 121 TO 126 + 172 TO 196 + 253 TO 336 + 404 TO 480 + 522 TO 580
// FOR THREE 65 TO 103 + 107 TO 109 + 123 TO 126 + 180 TO 196 + 280 TO 336 + 429 TO 480 + 541 TO 580
var pinConfigurationA = new List<dynamic>(){
new { Address = "1", Pin = Mcp23017Pin.A0, Direction = Mcp23017PinDirection.Output, Status = true },
new { Address = "2", Pin = Mcp23017Pin.A1, Direction = Mcp23017PinDirection.Output, Status = true },
new { Address = "3", Pin = Mcp23017Pin.A2, Direction = Mcp23017PinDirection.Output, Status = true},
new { Address = "4", Pin = Mcp23017Pin.A3, Direction = Mcp23017PinDirection.Output, Status = true },
new { Address = "5", Pin = Mcp23017Pin.A4, Direction = Mcp23017PinDirection.Output, Status = true },
new { Address = "6", Pin = Mcp23017Pin.A5, Direction = Mcp23017PinDirection.Output, Status = true },
new { Address = "7", Pin = Mcp23017Pin.A6, Direction = Mcp23017PinDirection.Output, Status = true },
new { Address = "8", Pin = Mcp23017Pin.A7, Direction = Mcp23017PinDirection.Output, Status = true },
//
new { Address = "9", Pin = Mcp23017Pin.B0, Direction = Mcp23017PinDirection.Input, PullUpResistor = true },
new { Address = "10", Pin = Mcp23017Pin.B1, Direction = Mcp23017PinDirection.Input, PullUpResistor = true },
new { Address = "11", Pin = Mcp23017Pin.B2, Direction = Mcp23017PinDirection.Input, PullUpResistor = true },
new { Address = "12", Pin = Mcp23017Pin.B3, Direction = Mcp23017PinDirection.Input, PullUpResistor = true },
new { Address = "13", Pin = Mcp23017Pin.B4, Direction = Mcp23017PinDirection.Input, PullUpResistor = true },
new { Address = "14", Pin = Mcp23017Pin.B5, Direction = Mcp23017PinDirection.Input, PullUpResistor = true },
new { Address = "15", Pin = Mcp23017Pin.B6, Direction = Mcp23017PinDirection.Input, PullUpResistor = true },
new { Address = "16", Pin = Mcp23017Pin.B7, Direction = Mcp23017PinDirection.Input, PullUpResistor = true }
};
var pinConfigurationB = new List<dynamic>(){
new { Address = "17", Pin = Mcp23017Pin.A0, Direction = Mcp23017PinDirection.Output, Status = true },
new { Address = "18", Pin = Mcp23017Pin.A1, Direction = Mcp23017PinDirection.Output, Status = true },
new { Address = "19", Pin = Mcp23017Pin.A2, Direction = Mcp23017PinDirection.Output, Status = true },
new { Address = "20", Pin = Mcp23017Pin.A3, Direction = Mcp23017PinDirection.Output, Status = true },
new { Address = "21", Pin = Mcp23017Pin.A4, Direction = Mcp23017PinDirection.Output, Status = true },
new { Address = "22", Pin = Mcp23017Pin.A5, Direction = Mcp23017PinDirection.Output, Status = true },
new { Address = "23", Pin = Mcp23017Pin.A6, Direction = Mcp23017PinDirection.Output, Status = true },
new { Address = "24", Pin = Mcp23017Pin.A7, Direction = Mcp23017PinDirection.Output, Status = true },
//
new { Address = "25", Pin = Mcp23017Pin.B0, Direction = Mcp23017PinDirection.Input, PullUpResistor = true },
new { Address = "26", Pin = Mcp23017Pin.B1, Direction = Mcp23017PinDirection.Input, PullUpResistor = true },
new { Address = "27", Pin = Mcp23017Pin.B2, Direction = Mcp23017PinDirection.Input, PullUpResistor = true },
new { Address = "28", Pin = Mcp23017Pin.B3, Direction = Mcp23017PinDirection.Input, PullUpResistor = true },
new { Address = "29", Pin = Mcp23017Pin.B4, Direction = Mcp23017PinDirection.Input, PullUpResistor = true },
new { Address = "30", Pin = Mcp23017Pin.B5, Direction = Mcp23017PinDirection.Input, PullUpResistor = true },
new { Address = "31", Pin = Mcp23017Pin.B6, Direction = Mcp23017PinDirection.Input, PullUpResistor = true },
new { Address = "32", Pin = Mcp23017Pin.B7, Direction = Mcp23017PinDirection.Input, PullUpResistor = true }
};
var pinConfigurationC = new List<dynamic>(){
new { Address = "33", Pin = Mcp23017Pin.A0, Direction = Mcp23017PinDirection.Output, Status = true },
new { Address = "34", Pin = Mcp23017Pin.A1, Direction = Mcp23017PinDirection.Output, Status = true },
new { Address = "35", Pin = Mcp23017Pin.A2, Direction = Mcp23017PinDirection.Output, Status = true },
new { Address = "36", Pin = Mcp23017Pin.A3, Direction = Mcp23017PinDirection.Output, Status = true },
new { Address = "37", Pin = Mcp23017Pin.A4, Direction = Mcp23017PinDirection.Output, Status = true },
new { Address = "38", Pin = Mcp23017Pin.A5, Direction = Mcp23017PinDirection.Output, Status = true },
new { Address = "39", Pin = Mcp23017Pin.A6, Direction = Mcp23017PinDirection.Output, Status = true },
new { Address = "40", Pin = Mcp23017Pin.A7, Direction = Mcp23017PinDirection.Output, Status = true },
//
new { Address = "41", Pin = Mcp23017Pin.B0, Direction = Mcp23017PinDirection.Input, PullUpResistor = true },
new { Address = "42", Pin = Mcp23017Pin.B1, Direction = Mcp23017PinDirection.Input, PullUpResistor = true },
new { Address = "43", Pin = Mcp23017Pin.B2, Direction = Mcp23017PinDirection.Input, PullUpResistor = true },
new { Address = "44", Pin = Mcp23017Pin.B3, Direction = Mcp23017PinDirection.Input, PullUpResistor = true },
new { Address = "45", Pin = Mcp23017Pin.B4, Direction = Mcp23017PinDirection.Input, PullUpResistor = true },
new { Address = "46", Pin = Mcp23017Pin.B5, Direction = Mcp23017PinDirection.Input, PullUpResistor = true },
new { Address = "47", Pin = Mcp23017Pin.B6, Direction = Mcp23017PinDirection.Input, PullUpResistor = true },
new { Address = "48", Pin = Mcp23017Pin.B7, Direction = Mcp23017PinDirection.Input, PullUpResistor = true }
};
/* var pinConfigurationD = new List<dynamic>(){
new { Address = "49", Pin = Mcp23017Pin.A0, Direction = Mcp23017PinDirection.Output, Status = true },
new { Address = "50", Pin = Mcp23017Pin.A1, Direction = Mcp23017PinDirection.Output, Status = true },
new { Address = "51", Pin = Mcp23017Pin.A2, Direction = Mcp23017PinDirection.Output, Status = true },
new { Address = "52", Pin = Mcp23017Pin.A3, Direction = Mcp23017PinDirection.Output, Status = true },
new { Address = "53", Pin = Mcp23017Pin.A4, Direction = Mcp23017PinDirection.Output, Status = true },
new { Address = "54", Pin = Mcp23017Pin.A5, Direction = Mcp23017PinDirection.Output, Status = true },
new { Address = "55", Pin = Mcp23017Pin.A6, Direction = Mcp23017PinDirection.Output, Status = true },
new { Address = "56", Pin = Mcp23017Pin.A7, Direction = Mcp23017PinDirection.Output, Status = true },
//
new { Address = "57", Pin = Mcp23017Pin.B0, Direction = Mcp23017PinDirection.Input, PullUpResistor = true },
new { Address = "58", Pin = Mcp23017Pin.B1, Direction = Mcp23017PinDirection.Input, PullUpResistor = true },
new { Address = "59", Pin = Mcp23017Pin.B2, Direction = Mcp23017PinDirection.Input, PullUpResistor = true },
new { Address = "60", Pin = Mcp23017Pin.B3, Direction = Mcp23017PinDirection.Input, PullUpResistor = true },
new { Address = "61", Pin = Mcp23017Pin.B4, Direction = Mcp23017PinDirection.Input, PullUpResistor = true },
new { Address = "62", Pin = Mcp23017Pin.B5, Direction = Mcp23017PinDirection.Input, PullUpResistor = true },
new { Address = "63", Pin = Mcp23017Pin.B6, Direction = Mcp23017PinDirection.Input, PullUpResistor = true },
new { Address = "64", Pin = Mcp23017Pin.B7, Direction = Mcp23017PinDirection.Input, PullUpResistor = true }
};
var pinConfigurationE = new List<dynamic>(){
new { Address = "65", Pin = Mcp23017Pin.A0, Direction = Mcp23017PinDirection.Output, Status = true },
new { Address = "66", Pin = Mcp23017Pin.A1, Direction = Mcp23017PinDirection.Output, Status = true },
new { Address = "67", Pin = Mcp23017Pin.A2, Direction = Mcp23017PinDirection.Output, Status = true },
new { Address = "68", Pin = Mcp23017Pin.A3, Direction = Mcp23017PinDirection.Output, Status = true },
new { Address = "69", Pin = Mcp23017Pin.A4, Direction = Mcp23017PinDirection.Output, Status = true },
new { Address = "70", Pin = Mcp23017Pin.A5, Direction = Mcp23017PinDirection.Output, Status = true },
new { Address = "71", Pin = Mcp23017Pin.A6, Direction = Mcp23017PinDirection.Output, Status = true },
new { Address = "72", Pin = Mcp23017Pin.A7, Direction = Mcp23017PinDirection.Output, Status = true },
//
new { Address = "73", Pin = Mcp23017Pin.B0, Direction = Mcp23017PinDirection.Input, PullUpResistor = true },
new { Address = "74", Pin = Mcp23017Pin.B1, Direction = Mcp23017PinDirection.Input, PullUpResistor = true },
new { Address = "75", Pin = Mcp23017Pin.B2, Direction = Mcp23017PinDirection.Input, PullUpResistor = true },
new { Address = "76", Pin = Mcp23017Pin.B3, Direction = Mcp23017PinDirection.Input, PullUpResistor = true },
new { Address = "77", Pin = Mcp23017Pin.B4, Direction = Mcp23017PinDirection.Input, PullUpResistor = true },
new { Address = "78", Pin = Mcp23017Pin.B5, Direction = Mcp23017PinDirection.Input, PullUpResistor = true },
new { Address = "79", Pin = Mcp23017Pin.B6, Direction = Mcp23017PinDirection.Input, PullUpResistor = true },
new { Address = "80", Pin = Mcp23017Pin.B7, Direction = Mcp23017PinDirection.Input, PullUpResistor = true }
};
*/
bool[] pinStatusA = new bool[16];
bool[] pinStatusB = new bool[16];
bool[] pinStatusC = new bool[16];
/* bool[] pinStatusD = new bool[16];
bool[] pinStatusE = new bool[16];
*/
Reply
Answers (
1
)
Gridview Editing issue
Update Query