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

C#

 
AnswerRe: Storing File Path on Database Pin
AmitGajjar25-Aug-12 22:20
professionalAmitGajjar25-Aug-12 22:20 
AnswerRe: Storing File Path on Database Pin
OriginalGriff25-Aug-12 22:34
mveOriginalGriff25-Aug-12 22:34 
QuestionRe: Storing File Path on Database Pin
Eddy Vluggen25-Aug-12 23:34
professionalEddy Vluggen25-Aug-12 23:34 
AnswerRe: Storing File Path on Database Pin
ASPnoob26-Aug-12 0:27
ASPnoob26-Aug-12 0:27 
GeneralRe: Storing File Path on Database Pin
Eddy Vluggen26-Aug-12 0:40
professionalEddy Vluggen26-Aug-12 0:40 
QuestionChange Combobox Look in WPF Pin
a.fatemeh25-Aug-12 9:24
a.fatemeh25-Aug-12 9:24 
AnswerRe: Change Combobox Look in WPF Pin
Abhinav S25-Aug-12 18:31
Abhinav S25-Aug-12 18:31 
QuestionIndexers Pin
ripples24-Aug-12 23:59
ripples24-Aug-12 23:59 
Hello
I am trying to write a program to input and display 10 employee details using indexers.I am stuck please help.
[code]
using System;

namespace EmployeeIndexer
{
    class Employee
    {
        string[] edept=new string[10];
        string[] ename=new string[10];
        int[] eno=new int[10];
        int[] esal=new int[10];
        int index = 0;

        public Employee()
        {
            edept[index] = "";
            ename[index] = "";
            eno[index] = 0;
            esal[index] = 0;
        }

        public void AddRec(string d, string n, int no, int s)
        {
            edept[index] = d;
            ename[index] = n;
            eno[index] = no;
            esal[index] = s;
        }

        public void this[int pos]
        {
            get
            {
                Console.WriteLine("{0} {1} {2} {3}",edept[pos],ename[pos],eno[pos],esal[pos]);              
            }
        }
    }

    class Employee_List
    {
        Employee[] e;
        int size=0;

        public Employee_List()
        {
            e = new Employee[10];
        }
        public void AddFunc()
        {
            string n, d;
            int s, no;

            Console.WriteLine("Enter the number of records you want to add:");
            size = Int32.Parse(Console.ReadLine());

            for (int i = 0; i < size; i++)
            {
                Console.WriteLine("Record Number {0}",i);
                Console.WriteLine("Name:");
                n = Console.ReadLine();
                Console.WriteLine("Number:");
                no = Int32.Parse(Console.ReadLine());
                Console.WriteLine("Dept:");
                d = Console.ReadLine();
                Console.WriteLine("Salary:");
                s = Int32.Parse(Console.ReadLine());

                e[i].AddRec(d,n,no,s);
            }
        }

        public void Disp()
        {
            for (int i = 0; i < size; i++)
            {
                Console.WriteLine("Record Number {0}",i);
                Console.WriteLine(e[i]);
            }
        }
    }

    class Main_Class
    {
        public static void Main()
        {
            while (true)
            {
                Console.WriteLine("Menu");
                Console.WriteLine("1.Add 2.Display 3.Exit");
                Console.WriteLine("Choice:");
                int c = Int32.Parse(Console.ReadLine());

                switch (c)
                {
                    case 1:
                        Employee_List el = new Employee_List();
                        el.AddFunc();
                        break;

                    case 2:
                        Employee_List e2 = new Employee_List();
                        e2.Disp();
                        break;

                    case 3:
                        return;
                }

            }
        }
    }
    
}

I am new to C# so pardon my mistakes.
[/code]
AnswerRe: Indexers Pin
Wes Aday25-Aug-12 0:12
professionalWes Aday25-Aug-12 0:12 
AnswerRe: Indexers Pin
DaveyM6925-Aug-12 0:37
professionalDaveyM6925-Aug-12 0:37 
AnswerRe: Indexers Pin
PIEBALDconsult25-Aug-12 4:40
mvePIEBALDconsult25-Aug-12 4:40 
AnswerRe: Indexers Pin
Richard MacCutchan25-Aug-12 7:07
mveRichard MacCutchan25-Aug-12 7:07 
GeneralRe: Indexers Pin
ripples25-Aug-12 8:52
ripples25-Aug-12 8:52 
Questioncan this be done without using 'dynamic: build a list of KeyValuePairs, where each item's Type varies ? Pin
BillWoodruff24-Aug-12 20:31
professionalBillWoodruff24-Aug-12 20:31 
AnswerRe: can this be done without using 'dynamic: build a list of KeyValuePairs, where each item's Type varies ? Pin
DaveyM6925-Aug-12 0:13
professionalDaveyM6925-Aug-12 0:13 
GeneralRe: can this be done without using 'dynamic: build a list of KeyValuePairs, where each item's Type varies ? Pin
BillWoodruff25-Aug-12 11:25
professionalBillWoodruff25-Aug-12 11:25 
AnswerRe: could this be done without dynamic Pin
Martijn Kok25-Aug-12 0:59
Martijn Kok25-Aug-12 0:59 
GeneralRe: could this be done without dynamic Pin
BillWoodruff25-Aug-12 11:33
professionalBillWoodruff25-Aug-12 11:33 
Questionasp.net Pin
Abubakar Shaikh .24-Aug-12 20:05
Abubakar Shaikh .24-Aug-12 20:05 
AnswerRe: asp.net Pin
Richard MacCutchan24-Aug-12 21:57
mveRichard MacCutchan24-Aug-12 21:57 
AnswerRe: asp.net Pin
Abhinav S25-Aug-12 2:38
Abhinav S25-Aug-12 2:38 
AnswerRe: asp.net Pin
Dave Kreskowiak25-Aug-12 4:23
mveDave Kreskowiak25-Aug-12 4:23 
QuestionProblem in datagridviewDeleteColumn Pin
Member 925960624-Aug-12 19:44
Member 925960624-Aug-12 19:44 
QuestionHow To Binding A List Of Frame? Pin
Bardiamarzbani24-Aug-12 9:42
Bardiamarzbani24-Aug-12 9:42 
AnswerRe: How To Binding A List Of Frame? Pin
Wes Aday24-Aug-12 10:46
professionalWes Aday24-Aug-12 10:46 

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.