Click here to Skip to main content
15,896,118 members
Home / Discussions / C#
   

C#

 
GeneralRe: Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. - why? Pin
turbosupramk32-Jan-15 8:46
turbosupramk32-Jan-15 8:46 
GeneralRe: Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. - why? Pin
Dave Kreskowiak2-Jan-15 8:49
mveDave Kreskowiak2-Jan-15 8:49 
GeneralRe: Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. - why? Pin
turbosupramk32-Jan-15 11:10
turbosupramk32-Jan-15 11:10 
GeneralRe: Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. - why? Pin
turbosupramk33-Jan-15 19:13
turbosupramk33-Jan-15 19:13 
GeneralRe: Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. - why? Pin
Dave Kreskowiak4-Jan-15 4:30
mveDave Kreskowiak4-Jan-15 4:30 
GeneralRe: Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. - why? Pin
turbosupramk34-Jan-15 6:34
turbosupramk34-Jan-15 6:34 
Questionarray property Pin
TMattC1-Jan-15 5:13
TMattC1-Jan-15 5:13 
AnswerRe: array property Pin
Thomas Daniels1-Jan-15 5:29
mentorThomas Daniels1-Jan-15 5:29 
There are some ways you can do. What to choose, depends on your application, but most likely, way 1 and 2 will be most helpful to you.

  • Use an array, as you did. If you do this, check for the length when the array is changed:
    C#
    set
    {
        if (value.Length == 3)
        {
            request = value;
        }
        else
        {
            throw new Exception("Length of Request must be 3.");
        }
    }

  • Use a Tuple: http://msdn.microsoft.com/en-us/library/system.tuple%28v=vs.110%29.aspx[^]
    C#
    private Tuple<char, char, char> request;
    
    public Package()
    {
        request = new Tuple<char, char, char>('\0', '\0', '\0');
    }
    
    public Tuple<char, char, char> Request
    {
        get { return request; }
        set { request = value; }
    }

    Items in the Tuple can be accessed like Request.Item1, Request.Item2, Request.Item3.
  • As properties in your class. Personally, I wouldn't use this unless it is really necessary for some reason.
    C#
    private char _char1;
    private char _char2;
    private char _char3;
    
    public Package()
    {
        _char1 = _char2 = _char3 = '\0';
    }
    
    public char Char1
    {
        get { return _char1; }
        set { _char1 = value; }
    }
    // and so on

The quick red ProgramFOX jumps right over the Lazy<Dog>.

GeneralRe: array property Pin
PIEBALDconsult1-Jan-15 5:47
mvePIEBALDconsult1-Jan-15 5:47 
AnswerRe: array property Pin
OriginalGriff1-Jan-15 6:07
mveOriginalGriff1-Jan-15 6:07 
GeneralRe: array property Pin
harold aptroot1-Jan-15 6:16
harold aptroot1-Jan-15 6:16 
AnswerRe: array property Pin
BillWoodruff1-Jan-15 9:23
professionalBillWoodruff1-Jan-15 9:23 
AnswerRe: array property Pin
BillWoodruff2-Jan-15 2:48
professionalBillWoodruff2-Jan-15 2:48 
Question(solved) Multiple reads of a file when it is open in another application ? Pin
BillWoodruff1-Jan-15 4:15
professionalBillWoodruff1-Jan-15 4:15 
AnswerRe: Multiple reads of a file when it is open in another application ? Pin
OriginalGriff1-Jan-15 4:42
mveOriginalGriff1-Jan-15 4:42 
GeneralRe: Multiple reads of a file when it is open in another application ? Pin
BillWoodruff1-Jan-15 6:03
professionalBillWoodruff1-Jan-15 6:03 
GeneralRe: Multiple reads of a file when it is open in another application ? Pin
OriginalGriff1-Jan-15 6:12
mveOriginalGriff1-Jan-15 6:12 
GeneralRe: Multiple reads of a file when it is open in another application ? Pin
BillWoodruff1-Jan-15 21:55
professionalBillWoodruff1-Jan-15 21:55 
GeneralRe: Multiple reads of a file when it is open in another application ? Pin
OriginalGriff1-Jan-15 23:05
mveOriginalGriff1-Jan-15 23:05 
AnswerRe: Multiple reads of a file when it is open in another application ? Pin
Pete O'Hanlon1-Jan-15 23:04
mvePete O'Hanlon1-Jan-15 23:04 
GeneralRe: Multiple reads of a file when it is open in another application ? Pin
BillWoodruff2-Jan-15 2:22
professionalBillWoodruff2-Jan-15 2:22 
QuestionReference to array element Pin
Krishnakumartg31-Dec-14 22:55
Krishnakumartg31-Dec-14 22:55 
AnswerRe: Reference to array element Pin
OriginalGriff31-Dec-14 23:56
mveOriginalGriff31-Dec-14 23:56 
GeneralRe: Reference to array element Pin
BillWoodruff1-Jan-15 4:24
professionalBillWoodruff1-Jan-15 4:24 
GeneralRe: Reference to array element Pin
OriginalGriff1-Jan-15 4:34
mveOriginalGriff1-Jan-15 4:34 

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.