Tag: C#的

我怎样才能正确的前缀一个单词“一”和“一个”?

我有一个.NET应用程序,在给定一个名词的情况下,我希望它用“a”或“an”正确地加上前缀。 我该怎么做? 在你认为答案是简单地检查第一个字母是否是元音之前,请考虑以下短语: 一个诚实的错误 一辆二手车

在C#中使用string键types的不区分大小写字典

如果我有一个Dictionary<String,…>是否有可能使像ContainsKey这样的方法不区分大小写? 这似乎是相关的,但我没有正确理解: c#字典:通过声明使关键不区分大小写

如何在后面的代码中访问附加属性?

我在我的XAML中有一个矩形,并想在后面的代码中更改它的Canvas.Left属性: <UserControl x:Class="Second90.Page" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="400" Height="300" KeyDown="txt_KeyDown"> <Canvas> <Rectangle Name="theObject" Canvas.Top="20" Canvas.Left="20" Width="10" Height="10" Fill="Gray"/> </Canvas> </UserControl> 但是这不起作用: private void txt_KeyDown(object sender, KeyEventArgs e) { theObject.Canvas.Left = 50; } 有谁知道这是什么语法?

#if 0 … #endif块究竟做了什么?

在C / C ++中 在#if 0 / #endif块之间放置的代码会发生什么变化? #if 0 //Code goes here #endif 代码是否被跳过,因此不会被执行?

c#从列表中删除项目

我有一个列表存储在结果列表如下: var resultlist = results.ToList(); 看起来像这样 ID FirstName LastName — ——— ——– 1 Bill Smith 2 John Wilson 3 Doug Berg 如何从列表中删除ID 2?

防伪令牌问题(MVC 5)

我有一个反伪造令牌的问题:(我已经创build了我自己的用户类,工作正常,但现在我得到一个错误,每当我去/帐户/注册页面。错误是: types为“ http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier ”或“ http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider ”的声明是不在提供的ClaimsIdentity上。 要启用基于声明的身份validation的防伪标记支持,请validationconfiguration的声明提供程序是否在其生成的ClaimsIdentity实例上提供了这两个声明。 如果configuration的声明提供程序使用不同的声明types作为唯一标识符,则可以通过设置静态属性AntiForgeryConfig.UniqueClaimTypeIdentifier来configuration它。 我发现这篇文章: AntiForgeryToken: A Claim of Type NameIdentifier or IdentityProvider Was Not Present on Provided ClaimsIdentity 所以我改变了我的Application_Start方法: protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.Email; } 但是当我这样做,我得到这个错误: 提供的ClaimsIdentity中没有“ http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress ”types的声明。 有没有人遇到过这个? 如果是这样,你知道如何解决它? 提前欢呼, r3plica 更新1 这是我的自定义用户类: public class Profile : User, IProfile { public Profile() : […]

这种types的CollectionView不支持从与分派器线程不同的线程对其SourceCollection的更改

我有一个DataGrid,它是通过asynchronous方法从ViewModel填充数据。我的DataGrid是: <DataGrid ItemsSource="{Binding MatchObsCollection}" x:Name="dataGridParent" Style="{StaticResource EfesDataGridStyle}" HorizontalGridLinesBrush="#DADADA" VerticalGridLinesBrush="#DADADA" Cursor="Hand" AutoGenerateColumns="False" RowDetailsVisibilityMode="Visible" > 我正在使用http://www.amazedsaint.com/2010/10/asynchronous-delegate-command-for-your.html在我的viewmodel中实现asynchronous的方式。 这是我的viewmodel代码: public class MainWindowViewModel:WorkspaceViewModel,INotifyCollectionChanged { MatchBLL matchBLL = new MatchBLL(); EfesBetServiceReference.EfesBetClient proxy = new EfesBetClient(); public ICommand DoSomethingCommand { get; set; } public MainWindowViewModel() { DoSomethingCommand = new AsyncDelegateCommand( () => Load(), null, null, (ex) => Debug.WriteLine(ex.Message)); _matchObsCollection = new ObservableCollection<EfesBet.DataContract.GetMatchDetailsDC>(); […]

从c#中的string的末尾删除回车和换行符

如何从string的末尾删除回车符(\r)和新行符(\n) ?

System.DateTime.Now和System.DateTime.Today之间的区别

任何人都可以解释System.DateTime.Now和System.DateTime.Today在C#.NET中的区别? 每个可能的优点和缺点。

错误LNK2038:为'_ITERATOR_DEBUG_LEVEL'检测到不匹配:值'0'与main.obj中的值'2'不匹配

我已经阅读了很多解决我的问题,但没有帮助。 我试图干净,重build。 重新安装visual 2010并从专业改为终极。 但是我仍然不知道为什么我有这个错误。 我的项目是这样的:1 Exe解决scheme来testing我的静态库。 1个DLL解决scheme静态库。 被转换为dll的代码是使用来自1个名为ClassificationFramework的库的函数。 我提供这个库作为标题和CPP,所以基本上是源代码。 在Exe解决scheme中,我链接了我生成的库+一些其他库以运行它+ ClassificationFramework.dll。 一切工作正常,当我使用释放,但当我更改为debugging(因为我想debugging一些东西,我厌倦了在发布模式中跳过debugging器)我得到这个: 2>Link: 2> ClassificationFramework.lib(SampleClass.obj) : MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance 2>ClassificationFramework.lib(SampleClass.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in […]