BackgroundI have to call a method that needs to return a signed integer (see code block below) after converting from an unsigned integer. The reason for this is that I have to do bit-wise math that relies on the value starting out as an unsigned integer.I was thinking of doing the try/catch with checking method that MSDN describes here. My only problem with this method is that, while I do want to handle the exception in an appropriate manner... There is no real predicting what meanings that the numbers might have for the caller. What I mean is, whoever calls GetMode will use the value to look up a string that provides a further meaning of what the mode number actually means.mode = object.GetMode(3);Where GetMode is defined as follows.public int GetMode(int index){    UInt32 modeUint = 0;    int modeInt = 0;    // extract the number from the array    modeUint = this.myArray[index];    // convert to a signed integer    modeInt = Convert.ToInt32(modeUint);     return modeInt;}The Class StructureThe class is structured in the following way:Fields:myArraymyDictionarymodeIndex = 3Constructor Methods:Entry()Entry(UInt32 data)Public Accessor Methods:int GetMode(int index)int GetModeDescriptionSo the way that this class works, is...The class is constructed with an array of data.The class builds myArray as an exact copy of the data with which the class was constructed.The class constructs a dictionary from a very large XML file, which contains the meanings of the various mode(s).The class will then be accessed by an outsider, inquiring about the mode(s).If GetMode is called, the mode number will be returned (after being extracted from a fixed location within myArray.If GetModeDescription is called, first GetMode will be used to get the number associated with the mode. This number will in-turn be used as the key to look up a value from the dictionary in order to obtain the appropriate string description.QuestionI want to prevent mis-using one of the mode (i.e. catch the exception, return 0). So I was thinking of doing one of the following:Don't do anything about the exception, the user has violated my contract and it's their fault.Catch the exception, and rethrow it with the original message plus some additional information about how the number being returned is  not valid.Just re-throw the exception.Is one of these acceptable, or is there another way?
Overflow Exception Checking Problem
c#;exceptions;error handling;bitwise operators
If I understand correctly, your Question is if and how to check whether// convert to a signed integermodeInt = Convert.ToInt32(modeUint); throws an OverflowException because modeUint = this.myArray[index]; contains an unsigned integer that is too large to fit.I offer the following:Do not check here, because the erroneous data is already loaded into a member of your object (myArray)Do check in the constructor, where:The class builds myArray as an exact copy of the data with which the  class was constructed.and throw an appropriate exception there.