please help me what problem in this code

This is a discussion on please help me what problem in this code within the C# Programming forums, part of the General Programming Boards category; please help for this code it's didn't print the array element Code: public struct student { public string name; public ...

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    1

    Cool please help me what problem in this code

    please help for this code it's didn't print the array element
    Code:
    public struct student
        {
           public string name;
           public string gender;
           public int    tel;
           public string classe;
        }
        class Program
        {
            static void Main(string[] args)
            {
                Console.WriteLine("Enter the Number of student :");
                int x = int.Parse(Console.ReadLine());
                student []array = new student[x];
    
               
                
                int count=1;
                
                for (int i = 0; i < array.Length; i++)
                {
                    array[i] = new student();
                   Console.WriteLine("Enter info of student {0}",count);
                   Console.WriteLine("Name :");
                   array[i].name = Console.ReadLine();
                   Console.WriteLine("Gender :");
                   array[i].gender = Console.ReadLine();
                   Console.WriteLine("Tel :");
                   int tel = int.Parse(Console.ReadLine());
                   array[i].tel = tel;
                   Console.WriteLine("class :");
                   array[i].classe  = Console.ReadLine();
                   count++;
                  
                  }
    
                  Console.WriteLine(array[0]);
    i want print the element with index [0] please help me
    it is print like this school.student
    school name of project


  2. #2
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,471
    something like
    Code:
    Console.WriteLine("Name: {0}, Gender: {1}, Tel: {2}, Class: {3}",array[0].name, array[0].gender, ...);
    may help
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  3. #3
    Registered User
    Join Date
    Apr 2008
    Location
    USA
    Posts
    22

    Wink

    The ever impressive student register application using an array lab exercise...yummy!

    Student GPA anyone??

    First year C# is a pain in the buttocks, is it not?

    Welcome to Hell!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Code problem
    By sybariticak47 in forum C++ Programming
    Replies: 9
    Last Post: 02-28-2006, 10:50 AM
  2. Problem with game code.
    By ajdspud in forum C++ Programming
    Replies: 5
    Last Post: 02-14-2006, 05:39 PM
  3. problem with selection code
    By DavidP in forum Game Programming
    Replies: 1
    Last Post: 06-14-2004, 01:05 PM
  4. Replies: 5
    Last Post: 12-03-2003, 04:47 PM
  5. Help with code for simple Y2K problem
    By Mule in forum C++ Programming
    Replies: 3
    Last Post: 03-05-2003, 11:53 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21