locked
CS1518 RRS feed

  • Question

  • well i am trying to solve this but i am having lot of error's 

    need some help 

    the program is-------

    using System;
    using System.Linq;
    namespace LargestSmallest
    {
     class Program
     {
     public static void Main(string[]args)
      {
       int n;
       float large,small;
       int[]a =new int[50];
       Console.WriteLine("Enter The size of array :");
       string s= Console.ReadLine();
       n=Int32.Parse(s);
       Console.WriteLine("Enter the array elements:");
       for(int i=0;i<n;i++)
       {
        string s1= Console.ReadLine();
        a[i]=Int32.Parse(s1);
       }
      }
     }
     Console.WriteLine(" ");
     large = a[s];
     small = a[s1];
     for(int i=1;i<n;i++)
     {
      if(a[i]>large)
      large=a[i];
      else if(a[i]<small)
      small=a[i];
     }
     Console.WriteLine("Largest element in the array is {0}", large);
     Console.WriteLine("Smallest element in the array is {0}", small);
     Console.ReadLine();
     }
    }

    Thursday, February 13, 2014 1:02 PM

Answers

  • Hi,

    Welcome to MSDN.

    This forum is to discuss and ask questions about the Visual Studio Debugging tools, Visual Studio Profiler tools, and Visual Studio Ultimate IntelliTrace, not include how to solve development issues of coding.

    I found that there are some errors in your code, I tested it with some editions.

    using System;
    using System.Linq;
    
    namespace CS1518By0214
    {
        class Program
        {
            static void Main(string[] args)
            {
                int n;
                float large, small;
                
                Console.WriteLine("Enter The size of array :");
                string s = Console.ReadLine();
                n = Int32.Parse(s);
                int[] a = new int[n];
                Console.WriteLine("Enter the array elements:");
                for (int i = 0; i < n; i++)
                {
                    string s1 = Console.ReadLine();
                    a[i] = Int32.Parse(s1);
                }
    
                Console.WriteLine(" ");
                large = a[0];
                small = a[0];
                for (int i = 1; i < n; i++)
                {
                    if (a[i] > large)
                        large = a[i];
                    else if (a[i] < small)
                        small = a[i];
                }
                Console.WriteLine("Largest element in the array is {0}", large);
                Console.WriteLine("Smallest element in the array is {0}", small);
                Console.ReadLine();
            }
        }
    }

    That works fine, you could test whether this issue is related to your code by change it to this one above.

    1. If it has the same issue, you could test it in another machine to check whether it is related to your Visual Studio.

    If it works fine in another machine, you could share that detailed information about that error with us by sharing the project which has been built and the screenshot.

    You could upload that project and the screenshot to skydrive, then share that link with us.

    I will test it in my side.

    2. If it works fine with this code, I would suggest you consider posting this issue in the following forum:

    Visual Studio Languages forums .NET Framework forums Visual C#

    Thanks for your understanding.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    • Edited by Carl Cai Friday, February 14, 2014 8:19 AM
    • Marked as answer by Carl Cai Wednesday, February 19, 2014 9:40 AM
    Friday, February 14, 2014 2:42 AM