本文整理汇总了C#中ReadOnlyCollection.IndexOf方法的典型用法代码示例。如果您正苦于以下问题:C# ReadOnlyCollection.IndexOf方法的具体用法?C# ReadOnlyCollection.IndexOf怎么用?C# ReadOnlyCollection.IndexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReadOnlyCollection
的用法示例。
在下文中一共展示了ReadOnlyCollection.IndexOf方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnNavigatedTo
public async override void OnNavigatedTo(NavigatedToEventArgs e, Dictionary<string, object> viewModelState)
{
string errorMessage = string.Empty;
try
{
var productNumber = e.Parameter as string;
var selectedProduct = await _productCatalogRepository.GetProductAsync(productNumber);
var productViewModels = (await _productCatalogRepository.GetProductsAsync(selectedProduct.SubcategoryId))
.Select(product => new ProductViewModel(product, _shoppingCartRepository, _alertService, _resourceLoader));
var items = new ReadOnlyCollection<ProductViewModel>(productViewModels.ToList());
Items = items;
SelectedProduct = Items.First(p => p.ProductNumber == productNumber);
SelectedIndex = items.IndexOf(SelectedProduct);
Title = SelectedProduct.Title;
}
catch (Exception ex)
{
errorMessage = string.Format(CultureInfo.CurrentCulture, _resourceLoader.GetString("GeneralServiceErrorMessage"), Environment.NewLine, ex.Message);
}
if (!string.IsNullOrWhiteSpace(errorMessage))
{
await _alertService.ShowAsync(errorMessage, _resourceLoader.GetString("ErrorServiceUnreachable"));
}
if (e.NavigationMode != NavigationMode.New)
{
base.OnNavigatedTo(e, viewModelState);
}
}
示例2: IListIndexOfWorks
public void IListIndexOfWorks() {
IList<string> l = new ReadOnlyCollection<string>(new[] { "x", "y", "z" });
Assert.AreEqual(l.IndexOf("y"), 1);
Assert.AreEqual(l.IndexOf("a"), -1);
}
示例3: IListIndexOfUsesEqualsMethod
public void IListIndexOfUsesEqualsMethod() {
IList<C> l = new ReadOnlyCollection<C>(new[] { new C(1), new C(2), new C(3) });
Assert.AreEqual(l.IndexOf(new C(2)), 1);
Assert.AreEqual(l.IndexOf(new C(4)), -1);
}
示例4: checkContains
private static int checkContains(ReadOnlyCollection<String> coll, String str)
{
if (!coll.Contains(str))
{
return -1;
}
else
{
return coll.IndexOf(str);
}
}