Tag: C#的

Func <string,string>和delegate有什么区别?

我以两种forms看到代表: A. Func<string, string> convertMethod = lambda B. public delegate string convertMethod(string value); 我不确定这两者之间究竟有什么区别。 他们都是代表吗? 我相信第一个将使用lambda,第二个将有一个方法来实际执行工作。 我也可能会感到困惑。

不能将lambdaexpression式转换为types“System.Delegate”

这些都没有工作: _uiDispatcher.Invoke(() => { }); _uiDispatcher.Invoke(delegate() { }); 我想要做的就是在我的主UI线程上调用一个内联方法。 所以我在主线上调用了这个: _uiDispatcher = Dispatcher.CurrentDispatcher; 现在我想从另一个线程执行该线程上的一些代码。 我该怎么做? 我使用错误的语法? 请注意,这不是一个WPF应用程序; 我引用了WindowsBase所以我可以访问Dispatcher类。

托pipec + +和c + +之间的区别

主题标题实际上是我的问题。 第二个问题是:我什么时候使用这两个中的哪一个?

AuthenticateRequest事件

Q 1.我的理解FormsAuthenticationModule订阅了AuthenticateRequest事件,因此只有在这个事件被触发之后, FormsAuthenticationModule才会被调用。 但是下面的引用让我有些困惑: AuthenticateRequest事件表示configuration的authentication机制已经authentication了当前的请求。 上面的引用不是说当AuthenticateRequest事件发生时,请求(又名用户)已经被authentication了吗? 订阅AuthenticateRequest事件可确保在处理附加的模块或事件处理程序之前对请求进行身份validation。 据我了解这个引用,如果我们订阅AuthenticatedRequest ,那么我们的事件处理程序将在FormsAuthenticationModule之前被调用? 因此Application_AuthenticateRequest()将在FormsAuthenticationModule被调用之前调用? 问2.我从中学习的书,build议在Application_AuthenticateRequest()我们能够validation用户是否是特定angular色的成员,如果没有,我们可以自动添加用户: protected void Application_AuthenticateRequest(Object sender, EventArgs e) { if (User.Identity.IsAuthenticated && Roles.Enabled) { //here we can subscribe user to a role via Roles.AddUserToRole() } } 从上面的代码判断,在调用FormsAuthenticationModule之后调用Application_AuthenticateRequest() ,但是在别的地方,同一本书意味着在FormsAuthenticationModule之前调用Application_AuthenticateRequest() : Application_AuthenticateRequest在执行authentication之前被调用。 这是创build您自己的身份validation逻辑的起点。 我错过了什么? 感谢名单

我是否正确写入了我的第一个MSpec规格?

我正在写我的第一个MSpec规格,我想要一些指导。 我把规格留在了“待定”状态,但上下文已经填写完毕。 有什么改进吗? 作为参考,这是故事和第一个场景: Story: "Blog admin logs in to the system" As a blog writer I want to be able to log in to my blog So that I can write posts and administer my blog Scenario: "Logs in from the login page" Given the user enters in correct credentials for a user in […]

为Eclipse项目添加C / C ++特性

有谁知道如何通过UI为Eclipse项目添加C / C ++项目性质? 我正在导入一个项目,并使用最初在Visual Studio 4中启动的遗留代码进行工作,我真的希望尽可能多地使用Eclipse的帮助器。

如何立即触发timer.Elapsed事件

我正在使用System.Timers.Timer类创buildTimer.Elapsed事件的计时器。 事情是Timer.Elapsed事件只有在间隔时间过后才会被第一次触发。 有没有办法在启动计时器后立即boostTimer.Elapsed事件? 我无法findSystem.Timers.Timer类中的任何相关的属性。

任何makefile生成的好工具?

我正在寻找一个工具,可以为不同的编译器(gcc,microsoft vc ++,borland等)和不同的平台(Win,Linux,Mac)生成一个C / C ++项目的makefile。

C# – 从静态类获取静态属性的值

我试图循环通过一个简单的静态类中的一些静态属性,以填充他们的价值combobox,但有困难。 这是简单的课程: public static MyStaticClass() { public static string property1 = "NumberOne"; public static string property2 = "NumberTwo"; public static string property3 = "NumberThree"; } …和试图检索值的代码: Type myType = typeof(MyStaticClass); PropertyInfo[] properties = myType.GetProperties( BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly); foreach (PropertyInfo property in properties) { MyComboBox.Items.Add(property.GetValue(myType, null).ToString()); } 如果我不提供任何绑定标志,那么我得到大约57个属性,包括像System.Reflection.Module模块和其他各种我不关心的其他inheritance的东西。 我的3个声明的属性不存在。 如果我提供其他标志的各种组合,那么它总是返回0属性。 大。 我的静态类实际上是在另一个非静态类中声明的吗? 我究竟做错了什么?

在VC2013中不能编译

此Constexpr代码不在Visual Studio 2013版本12.0.21005.1 REL中编译 是否有一个新的Visual Studio编译器与constexpr一起工作? #include <iostream> constexpr int factorial(int n) { return n <= 1 ? 1 : (n * factorial(n – 1)); } int main(void) { const int fact_three = factorial(3); std::cout << fact_three << std::endl; return 0; } 编译输出: 1> ——开始生成:Project:Project1,configuration:Debug Win32 —— 1> Source.cpp 1> …. \ source.cpp(3):错误C2144:语法错误:'int'应该以';'开始 1> …. […]