Click here to Skip to main content
11,481,754 members (63,043 online)

.NET Framework

 
QuestionSMS forwarding through GSM modem Pin
Member 94607155-Oct-12 3:57
memberMember 94607155-Oct-12 3:57 
QuestionHow to force rendering to generate an ID? [modified] Pin
AtALossHere5-Oct-12 2:13
memberAtALossHere5-Oct-12 2:13 
AnswerRe: How to force rendering to generate an ID? Pin
Sandeep Mewara5-Oct-12 3:24
mvpSandeep Mewara5-Oct-12 3:24 
GeneralRe: How to force rendering to generate an ID? Pin
AtALossHere5-Oct-12 4:26
memberAtALossHere5-Oct-12 4:26 
GeneralRe: How to force rendering to generate an ID? Pin
Sandeep Mewara5-Oct-12 4:30
mvpSandeep Mewara5-Oct-12 4:30 
GeneralRe: How to force rendering to generate an ID? Pin
AtALossHere5-Oct-12 5:51
memberAtALossHere5-Oct-12 5:51 
AnswerRe: How to force rendering to generate an ID? Pin
AtALossHere5-Oct-12 5:58
memberAtALossHere5-Oct-12 5:58 
QuestionCustom Class Exception Management / Setup Pin
Mike-MadBadger4-Oct-12 2:40
memberMike-MadBadger4-Oct-12 2:40 
I'm trying to get my head around a good way to set up exception management in a custom class, if I understand some of the advice in CP articles and elsewhere correctly then something like this setup is 'a' good way:

Simplified case: A class encapsulates a 2D array and has an UpperBound property that takes a an integer and returns the UpperBound of that dimension (since it does not expose the array directly).

Rather than the UpperBound property testing that the integer is either 0 or 1, I should put the call to the array GetUpperBound(dimension) method in a Try block and catch the exceptions that can be thrown by the array method, then re-throw the exception from the encapsulating class with the array exception as the inner exception parameter. Is that smart?

Then if another method in the class uses the UpperBound property (in the encapsulating class) it should catch and re-throw the exceptions created by the UpperBound method (again with the inner exception as a parmater), hence the exception the programmer recieves has a trail directly from the methods they called through whatever path was then followed and ending up with the base exception thrown by the encapculated array.

For example:
	''' <summary>
	''' Gets the upper bound of the specified dimension in the matrix
	''' </summary>
	''' <param name="dimension">A zero based dimension of the matrix. Must be zero or one since the a Matrix is two dimensional</param>
	''' <value></value>
	''' <returns>The upper bound of the specified dimension</returns>
	''' <exception cref="IndexOutOfRangeException">This exception is thrown if the specified <paramref name="dimension"/><c> is less than zero or exceeds one, since the a Matrix is two dimensional</c></exception>
	''' <remarks></remarks>
	Public ReadOnly Property UpperBound(ByVal dimension As Integer) As Integer
		Get
			Try
				Return Me._matrix.GetUpperBound(dimension)
			Catch inex As IndexOutOfRangeException
				Throw New IndexOutOfRangeException("The dimension you specified is out of range for this matrix object. Matrix objects have only two dimensions, 0 and 1. See the inner exception for more detail.", inex)
			Catch ex As Exception
				Throw
			End Try
		End Get
	End Property

Then if I had another method in my class (call it Iterate for example) that needed the UpperBound of the rows (dimension = 0), say to use in a For loop, it would again do this in a Try block, call the UpperBound property and catch the exceptions thrown by the UpperBound property. So if somehow this latter method (Iterate) managed to make a call to UpperBound(2) then the programmer would see the Iterate method throw an IndexOutOfRange exception with the UpperBound exception as its inner exception and that in turn would have the array GertUpperBound exception as an inner exception.

Smart, dumb - other names? Advice?

Mike
AnswerRe: Custom Class Exception Management / Setup Pin
Pete O'Hanlon4-Oct-12 2:50
protectorPete O'Hanlon4-Oct-12 2:50 
GeneralRe: Custom Class Exception Management / Setup Pin
Mike-MadBadger4-Oct-12 3:27
memberMike-MadBadger4-Oct-12 3:27 
GeneralRe: Custom Class Exception Management / Setup Pin
Pete O'Hanlon4-Oct-12 3:32
protectorPete O'Hanlon4-Oct-12 3:32 
QuestionI need an idea for program Pin
Cihangir Giray Han3-Oct-12 23:02
memberCihangir Giray Han3-Oct-12 23:02 
AnswerRe: I need an idea for program Pin
Pete O'Hanlon3-Oct-12 23:08
protectorPete O'Hanlon3-Oct-12 23:08 
GeneralRe: I need an idea for program Pin
Cihangir Giray Han3-Oct-12 23:33
memberCihangir Giray Han3-Oct-12 23:33 
GeneralRe: I need an idea for program Pin
Pete O'Hanlon3-Oct-12 23:39
protectorPete O'Hanlon3-Oct-12 23:39 
GeneralRe: I need an idea for program Pin
Cihangir Giray Han4-Oct-12 2:47
memberCihangir Giray Han4-Oct-12 2:47 
GeneralRe: I need an idea for program Pin
Pete O'Hanlon4-Oct-12 2:51
protectorPete O'Hanlon4-Oct-12 2:51 
QuestionEntity Framework, Import Function Stored Procs & Data Services Pin
Stewart Judson2-Oct-12 0:57
memberStewart Judson2-Oct-12 0:57 
QuestionHow to use FileSystemWatcher Control ? Pin
DEEPAK9489@GMAIL.COM1-Oct-12 17:47
memberDEEPAK9489@GMAIL.COM1-Oct-12 17:47 
AnswerRe: How to use FileSystemWatcher Control ? Pin
JF20151-Oct-12 20:05
memberJF20151-Oct-12 20:05 
AnswerRe: How to use FileSystemWatcher Control ? Pin
Eddy Vluggen2-Oct-12 5:42
memberEddy Vluggen2-Oct-12 5:42 
QuestionHow to know .NET Framework, deeply? Pin
atoi_powered1-Oct-12 13:22
memberatoi_powered1-Oct-12 13:22 
AnswerRe: How to know .NET Framework, deeply? Pin
Eddy Vluggen2-Oct-12 5:40
memberEddy Vluggen2-Oct-12 5:40 
GeneralRe: How to know .NET Framework, deeply? Pin
isenthil2-Oct-12 7:27
memberisenthil2-Oct-12 7:27 
GeneralRe: How to know .NET Framework, deeply? Pin
atoi_powered2-Oct-12 9:23
memberatoi_powered2-Oct-12 9:23 

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

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


Advertise | Privacy | Mobile
Web04 | 2.8.150520.1 | Last Updated 23 May 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid