Click here to Skip to main content
16,005,120 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to open a application in IE7 Pin
sw_tech12330-Jan-09 0:44
sw_tech12330-Jan-09 0:44 
QuestionAccessing webcam parameters such as resulotion and mode Pin
Member 407064129-Jan-09 19:40
Member 407064129-Jan-09 19:40 
QuestionHow to solve delay in display of replaced text on a web page? How to reduce CPU usage which is caused due to 'foreach loop'? Pin
svt gdwl29-Jan-09 18:43
svt gdwl29-Jan-09 18:43 
AnswerRe: How to solve delay in display of replaced text on a web page? How to reduce CPU usage which is caused due to 'foreach loop'? Pin
Bharat Jain29-Jan-09 20:42
Bharat Jain29-Jan-09 20:42 
GeneralRe: How to solve delay in display of replaced text on a web page? How to reduce CPU usage which is caused due to 'foreach loop'? Pin
S. Senthil Kumar29-Jan-09 21:50
S. Senthil Kumar29-Jan-09 21:50 
GeneralRe: How to solve delay in display of replaced text on a web page? How to reduce CPU usage which is caused due to 'foreach loop'? Pin
Bharat Jain29-Jan-09 22:43
Bharat Jain29-Jan-09 22:43 
GeneralRe: How to solve delay in display of replaced text on a web page? How to reduce CPU usage which is caused due to 'foreach loop'? Pin
svt gdwl30-Jan-09 3:22
svt gdwl30-Jan-09 3:22 
QuestionException throwing - Advice required Pin
Imtiaz Murtaza29-Jan-09 18:35
Imtiaz Murtaza29-Jan-09 18:35 
Friends,
Quite frequently i need to throw exception from the code. But i don't want to write my custom exception class. Reason is that i don't have any dynamic data to be associated. In such situation, currently i am doing something like this:

skyColor = GetSkyColor();

if(skyColor == Blue)
{
Console.WriteLine("Its a day");
}
else if(skyColor == Black)
{
Console.WriteLine("It is night");
}
else
{
msg = String.Format("{0} is not a valid sky color", skyColor.ToString() );

throw new Exception(msg);
}

As you can see above i am throwing "Exception" which is considered as bad practice. The second option is that i use InvalidOperationException, but this exception is used when object state is not valid which is not the case here. Third option is that i write my own exception class InvalidSkyColorException. The case i described above is well qualified for custom exception as i can associate dynamic data SkyColor. But issue is that in most of the cases i don't even have dynamic data to associate. I just want to throw a string message. Now if i start writing my custom exception class for each of the situation, then there will be thousands of such classes in the project.

So what you guys suggest me in such cases. Shall i continue to throw generic "Exception" or use InvalidOperationException ? Or is there better solution ?

Imtiaz

AnswerRe: Exception throwing - Advice required Pin
Karmendra Suthar29-Jan-09 19:09
Karmendra Suthar29-Jan-09 19:09 
GeneralRe: Exception throwing - Advice required Pin
N a v a n e e t h29-Jan-09 19:26
N a v a n e e t h29-Jan-09 19:26 
AnswerRe: Exception throwing - Advice required Pin
Vikram A Punathambekar29-Jan-09 19:13
Vikram A Punathambekar29-Jan-09 19:13 
AnswerRe: Exception throwing - Advice required Pin
Bharat Jain29-Jan-09 19:22
Bharat Jain29-Jan-09 19:22 
AnswerRe: Exception throwing - Advice required Pin
Najmal29-Jan-09 22:16
Najmal29-Jan-09 22:16 
Questionjoin transaction Pin
devvvy29-Jan-09 14:39
devvvy29-Jan-09 14:39 
AnswerRe: join transaction Pin
N a v a n e e t h29-Jan-09 14:55
N a v a n e e t h29-Jan-09 14:55 
GeneralRe: join transaction Pin
devvvy29-Jan-09 15:00
devvvy29-Jan-09 15:00 
GeneralRe: join transaction Pin
N a v a n e e t h29-Jan-09 15:03
N a v a n e e t h29-Jan-09 15:03 
Questionhow much is java difficult?? Pin
Ali_10029-Jan-09 11:01
Ali_10029-Jan-09 11:01 
AnswerRe: how much is java difficult?? Pin
faehne29-Jan-09 11:08
faehne29-Jan-09 11:08 
AnswerRe: how much is java difficult?? Pin
PIEBALDconsult29-Jan-09 12:00
mvePIEBALDconsult29-Jan-09 12:00 
AnswerRe: how much is java difficult?? Pin
N a v a n e e t h29-Jan-09 14:38
N a v a n e e t h29-Jan-09 14:38 
GeneralRe: how much is java difficult?? Pin
PIEBALDconsult29-Jan-09 16:13
mvePIEBALDconsult29-Jan-09 16:13 
QuestionRe: how much is java difficult?? Pin
CPallini29-Jan-09 22:12
mveCPallini29-Jan-09 22:12 
AnswerRe: how much is java difficult?? Pin
Karmendra Suthar29-Jan-09 18:39
Karmendra Suthar29-Jan-09 18:39 
QuestionTrace output to command window. Pin
Member 232448329-Jan-09 10:22
Member 232448329-Jan-09 10:22 

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.