Click here to Skip to main content
15,917,456 members
Home / Discussions / C#
   

C#

 
GeneralRe: Proxy Classes - Copy/Paste Pre-compiler Pin
Iain Wiseman1-Dec-09 20:17
Iain Wiseman1-Dec-09 20:17 
GeneralRe: Proxy Classes - Copy/Paste Pre-compiler Pin
dan!sh 1-Dec-09 20:27
professional dan!sh 1-Dec-09 20:27 
GeneralRe: Proxy Classes - Copy/Paste Pre-compiler Pin
Dave Kreskowiak2-Dec-09 1:09
mveDave Kreskowiak2-Dec-09 1:09 
QuestionSelecting from datatable Pin
myinstincts1-Dec-09 18:17
myinstincts1-Dec-09 18:17 
AnswerRe: Selecting from datatable Pin
Giorgi Dalakishvili1-Dec-09 18:56
mentorGiorgi Dalakishvili1-Dec-09 18:56 
AnswerRe: Selecting from datatable Pin
dan!sh 1-Dec-09 19:07
professional dan!sh 1-Dec-09 19:07 
AnswerRe: Selecting from datatable Pin
Anurag Gandhi1-Dec-09 19:58
professionalAnurag Gandhi1-Dec-09 19:58 
Questionout of memory exception Pin
eswar pothula1-Dec-09 17:57
eswar pothula1-Dec-09 17:57 
AnswerRe: out of memory exception Pin
Saksida Bojan1-Dec-09 19:18
Saksida Bojan1-Dec-09 19:18 
Answerunreadable Pin
Luc Pattyn2-Dec-09 1:16
sitebuilderLuc Pattyn2-Dec-09 1:16 
QuestionReally need help with platform invoke Lotus Notes API in C# Pin
senorAli331-Dec-09 16:27
senorAli331-Dec-09 16:27 
AnswerRe: Really need help with platform invoke Lotus Notes API in C# Pin
Luc Pattyn1-Dec-09 16:51
sitebuilderLuc Pattyn1-Dec-09 16:51 
QuestionMulticast Delegate using MethodInfo Pin
hobbel2221-Dec-09 12:29
hobbel2221-Dec-09 12:29 
AnswerRe: Multicast Delegate using MethodInfo Pin
N a v a n e e t h1-Dec-09 17:04
N a v a n e e t h1-Dec-09 17:04 
GeneralRe: Multicast Delegate using MethodInfo Pin
hobbel2221-Dec-09 23:50
hobbel2221-Dec-09 23:50 
QuestionIs their a better way than using the Try/Catch statement in this source? Pin
venomation1-Dec-09 9:07
venomation1-Dec-09 9:07 
Hey I am a college student and recently figured out how to down/up cast types and get derived values form them.
I made a simply (certainly not elegant) experimental program for it but I dont want to use Try/Catch in the "ShowDetails" method. There must be a better way than this !
class Program
    {
        static List<IProduct> productList = new List<IProduct>();
        static void Main(string[] args)
        {
            Console.WriteLine("What product would you like to purchase");
            Console.WriteLine("1 Xbox");
            Console.WriteLine("2 Ps3");
            Console.Write("Number: ");
            char choice = Console.ReadLine()[0];
            Choice ch = Makedescision(choice);
            EvaluateDescision(ch);
            Console.ReadKey();
        }
        enum Choice { xbox = 1, ps3 = 2, nothing };

        static Choice Makedescision(char input)
        {
            if (input.Equals('1'))
            {
                return Choice.xbox;
            }
            else if (input.Equals('2'))
            {
                return Choice.ps3;
            }

            return Choice.nothing;

        }
        static void EvaluateDescision(Choice ch)
        {
            if (ch == Choice.xbox)
            {
                MakeNewXbox();
            }
            else if (ch == Choice.ps3)
            {
                MakeNewPs3();
            }
        }

        static void MakeNewXbox()
        {
            Xbox product = new Xbox();
            Console.WriteLine("Name your xbox");
            product.Name = Console.ReadLine();
            product.quantity = 2;
            product.Cost = 129.99m;
            productList.Add(product);
            ShowDetail(0);

        }
        static void MakeNewPs3()
        {
            Ps3 product = new Ps3();
            Console.WriteLine("Is new?");
            bool isNew = bool.Parse(Console.ReadLine());
            product.IsNew = isNew;
            product.Cost = 129.99m;
            productList.Add(product);
            ShowDetail(0);

        }

        static void ShowDetail(int i)
        {
            int quantity;
            bool detail;
            IProduct prod = (IProduct)productList[i];
            try
            {
                quantity = ((Xbox)(prod)).quantity;
                Console.WriteLine("quantity is " + quantity);
                
            }catch(Exception e)
            {
            }
            try
            {
                detail = ((Ps3)(prod)).IsNew;
                Console.WriteLine("is new? " + detail);
            }
            catch (Exception e)
            {
            }


        }
        
    }

AnswerRe: Is their a better way than using the Try/Catch statement in this source? Pin
OriginalGriff1-Dec-09 9:15
mveOriginalGriff1-Dec-09 9:15 
GeneralRe: Is their a better way than using the Try/Catch statement in this source? Pin
venomation1-Dec-09 9:24
venomation1-Dec-09 9:24 
GeneralRe: Is their a better way than using the Try/Catch statement in this source? Pin
OriginalGriff1-Dec-09 9:34
mveOriginalGriff1-Dec-09 9:34 
GeneralRe: Is their a better way than using the Try/Catch statement in this source? Pin
vtchris-peterson1-Dec-09 9:29
vtchris-peterson1-Dec-09 9:29 
GeneralRe: Is their a better way than using the Try/Catch statement in this source? Pin
venomation1-Dec-09 9:37
venomation1-Dec-09 9:37 
QuestionSandboxing with AppDomain Pin
softwarejaeger1-Dec-09 7:51
softwarejaeger1-Dec-09 7:51 
QuestionReading excel file in Vista x64 Pin
kmuthuk1-Dec-09 5:38
kmuthuk1-Dec-09 5:38 
AnswerRe: Reading excel file in Vista x64 Pin
Dave Kreskowiak1-Dec-09 5:47
mveDave Kreskowiak1-Dec-09 5:47 
GeneralRe: Reading excel file in Vista x64 Pin
kmuthuk1-Dec-09 5:55
kmuthuk1-Dec-09 5:55 

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.