C# Can';t在密封的分部类中使用外部类
我刚开始使用C#,现在正在尝试构建一个简单的windows应用商店应用程序。但是我不明白为什么找不到C# Can';t在密封的分部类中使用外部类,c#,visual-studio-2012,windows-store-apps,C#,Visual Studio 2012,Windows Store Apps,我刚开始使用C#,现在正在尝试构建一个简单的windows应用商店应用程序。但是我不明白为什么找不到ArrayList。在下面的代码中,我尝试在按钮中使用ArrayList,单击1()。我收到的错误是“找不到类型或命名空间名称“ArrayList””,但我使用的是System.Collections,其中包括ArrayList using System; using System.Collections; using System.Collections.Generic; using Syste
ArrayList
。在下面的代码中,我尝试在按钮中使用ArrayList
,单击1()。我收到的错误是“找不到类型或命名空间名称“ArrayList”
”,但我使用的是System.Collections
,其中包括ArrayList
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
// The Basic Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234237
namespace Statistics
{
/// <summary>
/// A basic page that provides characteristics common to most applications.
/// </summary>
public sealed partial class MainPage : Statistics.Common.LayoutAwarePage
{
public MainPage()
{
this.InitializeComponent();
}
/// <summary>
/// Populates the page with content passed during navigation. Any saved state is also
/// provided when recreating a page from a prior session.
/// </summary>
/// <param name="navigationParameter">The parameter value passed to
/// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
/// </param>
/// <param name="pageState">A dictionary of state preserved by this page during an earlier
/// session. This will be null the first time a page is visited.</param>
protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
{
}
/// <summary>
/// Preserves state associated with this page in case the application is suspended or the
/// page is discarded from the navigation cache. Values must conform to the serialization
/// requirements of <see cref="SuspensionManager.SessionState"/>.
/// </summary>
/// <param name="pageState">An empty dictionary to be populated with serializable state.</param>
protected override void SaveState(Dictionary<String, Object> pageState)
{
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
ArrayList data = new ArrayList();
}
private void TextBox_TextChanged_1(object sender, TextChangedEventArgs e)
{
}
}
}
使用系统;
使用系统集合;
使用System.Collections.Generic;
使用System.IO;
使用System.Linq;
使用Windows基金会;
使用Windows。
使用Windows.UI.Xaml;
使用Windows.UI.Xaml.Controls;
使用Windows.UI.Xaml.Controls.Primitives;
使用Windows.UI.Xaml.Data;
使用Windows.UI.Xaml.Input;
使用Windows.UI.Xaml.Media;
使用Windows.UI.Xaml.Navigation;
//基本页面项目模板记录在http://go.microsoft.com/fwlink/?LinkId=234237
命名空间统计信息
{
///
///提供大多数应用程序通用特性的基本页面。
///
公共密封部分类主页面:Statistics.Common.LayoutAwarePage
{
公共主页()
{
this.InitializeComponent();
}
///
///使用导航期间传递的内容填充页面。任何保存的状态也会
///从上一个会话重新创建页面时提供。
///
///传递给的参数值
///最初请求此页面时。
///
///此页在早期版本中保留的状态词典
///会话。第一次访问页面时,此值将为空。
受保护的覆盖无效加载状态(对象导航参数,字典页面状态)
{
}
///
///保留与此页关联的状态,以防应用程序挂起或
///页已从导航缓存中丢弃。值必须符合序列化
///的要求。
///
///要使用可序列化状态填充的空字典。
受保护的覆盖无效保存状态(字典页面状态)
{
}
私有无效按钮\u单击\u 1(对象发送者,路由目标)
{
ArrayList数据=新的ArrayList();
}
私有无效文本框\u TextChanged\u 1(对象发送者,textchangedventargs e)
{
}
}
}
您的目标是windows应用商店:这意味着您正在使用netcore框架。这不是常规的.NET框架
- 它有一些独特的东西
- 它缺少常规框架中的一些东西
- 有些东西有不同的特点
ArrayList
不包括在内。改用T列表<代码>列表就足够了,但是更具体的类型更好。您的目标是windows应用商店:这意味着您正在使用netcore框架。这不是常规的.NET框架
- 它有一些独特的东西
- 它缺少常规框架中的一些东西
- 有些东西有不同的特点
ArrayList
不包括在内。改用T列表<代码>列表就足够了,但是更具体的类型更好。winRT(windows应用商店)应用程序中不提供非泛型集合
使用常规列表类型:
List<T>
列表
非通用集合在winRT(windows应用商店)应用程序中不可用
使用常规列表类型:
List<T>
列表
奇怪;它适用于VS2012、.NET4.5(控制台应用程序);它在VS 2012、.NET 4.5(控制台应用程序)上运行。很抱歉出现了严重的延迟,我只想指出这个答案是完全正确的,但是,马克的答案更完整。很抱歉出现了严重的延迟,我只想指出这个答案是完全正确的,但是,马克的答案更完整