Error 1: an index with [] cannot be applied to the expression C:/Inetpub/wwwroot/StrigDs/Form5.cs 39 13 StrigDs of the "StrigDs. SeqList" type.

Source: Internet
Author: User

Error 1: an index with [] cannot be applied to the expression C:/Inetpub/wwwroot/StrigDs/Form5.cs 39 13 StrigDs of the "StrigDs. SeqList <T>" type.
Error:
SqList [0] = key; // This sentence is incorrect ????????????

Program:

Public class SeqList <T>
{
Public SeqList <T> sqList;

Public SeqList <T> GetLength ()
{
Return sqList. GetLength ();
}

Public int BinarySearch (SeqList <T> sqList, int key)
{
SqList [0] = key; // store the record to be searched
Int mid = 0;
Int flag =-1; // flag
Int low = 1; // set the lower limit of the initial interval
Int high = Convert. ToInt32 (sqList. GetLength (); // you can specify the upper limit of the initial interval.

// The record is not found.
While (low <= high)
{
// Middle
Mid = (low + high)/2;
If (sqList [0] = sqList [mid])
{
Flag = mid; // search successful, then save record to flag's
Break;
}
Else if (sqList [0] <sqList [mid])
{// Left binary Area
High = mid-1;

}
Else
{// Right binary Area
Low = Mid + 1;

}

}
If (flag> 0)
{
Console. writeline ("search is successful ");
Return flag;
}
Else
{
Console. writeline ("search is failed ");
Return-1;
}

}
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.