Click here to Skip to main content
15,888,461 members
Home / Discussions / C#
   

C#

 
Questionparameterized decimal point Pin
Jassim Rahma22-Jun-10 22:40
Jassim Rahma22-Jun-10 22:40 
AnswerRe: parameterized decimal point Pin
Covean22-Jun-10 23:31
Covean22-Jun-10 23:31 
GeneralRe: parameterized decimal point Pin
Jassim Rahma22-Jun-10 23:39
Jassim Rahma22-Jun-10 23:39 
QuestionExcel interop - 80080005 error [modified] Pin
hwswin22-Jun-10 22:36
hwswin22-Jun-10 22:36 
QuestionCopy values in column to another column Pin
shoubi22-Jun-10 22:32
shoubi22-Jun-10 22:32 
AnswerRe: Copy values in column to another column Pin
MayukhSen23-Jun-10 0:07
MayukhSen23-Jun-10 0:07 
AnswerRe: Copy values in column to another column Pin
yu-jian27-Jun-10 9:35
yu-jian27-Jun-10 9:35 
QuestionCannot call public method [newbie] Pin
jon-8022-Jun-10 22:01
professionaljon-8022-Jun-10 22:01 
I am coding this utility to test raising of an exception, however, I have noted that Visual Studio 2010 IDE does not allow me to call the ArithmeticUtilityException.Divide() method. Why?

I have also (desperately) tried to declare the class as static and the Divide() method as static, however, no joy either.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CustomException
{
    class Program
    {
        static void Main(string[] args)
        {
            ArithmeticUtilityException utility = new ArithmeticUtilityException();
            ///Decimal myNumber = ArithmeticUtilityException.???
        }
    }

    public class ArithmeticUtilityException : ApplicationException
    { 
        public ArithmeticUtilityException() : base() {}
        public ArithmeticUtilityException(string message) : base(message) {}
        public ArithmeticUtilityException(string message, Exception inner) : base(message, inner) {}
    }

    public static class ArithmethicUtility
    {
        public decimal Divide(decimal number, decimal divisor)
        {
            try
            { return number / divisor; }
            catch (Exception err)
            {
                /*  
                 * Create an instance of the specialized exception class, and, 
                 * place the original error in the InnerException property. 
                 */
                ArithmeticUtilityException errNew = new ArithmeticUtilityException("Divide by zero", err);
                throw errNew;
            }
        }
    }
}



Confused | :confused:


NOTES
1. Related link Static Classes and Static Class Members (C# Programming Guide)

2. Personal note. ..\Training\CustomException.
Jon

AnswerRe: Cannot call public method [newbie] Pin
OriginalGriff22-Jun-10 22:04
mveOriginalGriff22-Jun-10 22:04 
GeneralRe: Cannot call public method [newbie] Pin
jon-8022-Jun-10 22:12
professionaljon-8022-Jun-10 22:12 
GeneralRe: Cannot call public method [newbie] Pin
OriginalGriff22-Jun-10 22:24
mveOriginalGriff22-Jun-10 22:24 
QuestionHow to use a com dll without embedded typelibrary in it? Pin
kcynic22-Jun-10 20:53
kcynic22-Jun-10 20:53 
AnswerMessage Closed Pin
22-Jun-10 21:02
stancrm22-Jun-10 21:02 
GeneralRe: How to use a com dll without embedded typelibrary in it? Pin
kcynic22-Jun-10 21:12
kcynic22-Jun-10 21:12 
GeneralRe: How to use a com dll without embedded typelibrary in it? Pin
Covean22-Jun-10 21:46
Covean22-Jun-10 21:46 
GeneralRe: How to use a com dll without embedded typelibrary in it? Pin
kcynic22-Jun-10 22:35
kcynic22-Jun-10 22:35 
GeneralRe: How to use a com dll without embedded typelibrary in it? Pin
Covean23-Jun-10 0:41
Covean23-Jun-10 0:41 
GeneralRe: How to use a com dll without embedded typelibrary in it? Pin
kcynic23-Jun-10 19:30
kcynic23-Jun-10 19:30 
GeneralMessage Closed Pin
23-Jun-10 2:04
stancrm23-Jun-10 2:04 
GeneralRe: How to use a com dll without embedded typelibrary in it? Pin
kcynic23-Jun-10 19:49
kcynic23-Jun-10 19:49 
Questionclass relationships [modified] Pin
netJP12L22-Jun-10 19:41
netJP12L22-Jun-10 19:41 
AnswerRe: class relationships Pin
phil.o22-Jun-10 23:54
professionalphil.o22-Jun-10 23:54 
GeneralRe: class relationships Pin
netJP12L23-Jun-10 2:59
netJP12L23-Jun-10 2:59 
AnswerRe: class relationships Pin
DaveyM6923-Jun-10 3:39
professionalDaveyM6923-Jun-10 3:39 
GeneralRe: class relationships Pin
netJP12L23-Jun-10 5:11
netJP12L23-Jun-10 5:11 

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.