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

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.