草庐IT

event_generate

全部标签

c# - UIElement.AddHandler() 与 .Event += 定义

问题的第一部分:这2个事件注册之间有什么区别?_popUp.AddHandler(PreviewMouseLeftButtonDownEvent,newMouseButtonEventHandler(PopUp_PreviewMouseLeftButtonDown));_popUp.PreviewMouseLeftButtonDown+=newMouseButtonEventHandler(_popUp_PreviewMouseLeftButtonDown);问题的第二部分:或最终与popUp.Opened+=PopUp_Opened; 最佳答案

c# - 当我尝试重命名方法时,为什么 Visual Studio 告诉我有 "compiler generated references"?

我有一个名为FormattedJoin()的方法在名为ArrayUtil的实用程序类中.我尝试重命名FormattedJoin()只是Join()因为它的行为类似于.NET的string.Join()所以我认为使用相同的名称是有意义的。但是,当我尝试使用VisualStudio重命名该方法时,我收到此警告:Thismembermayhavecompilergeneratedreferenceswiththesamename.Refactoringthememberwillnotupdatethesereferences,whichmayintroducesemanticchangesa

c# - event 关键字的真正作用是什么?

publicdelegatevoidSecondChangedHandler(objectclock,TimeInfoEventArgstimeInformation);publiceventSecondChangedHandlerSecondChanged;我已经基于这个写了一个时钟article.现在,如果我删除event关键字,我会得到相同的结果,那么event到底做了什么? 最佳答案 它的编译方式不同。做到了有人做不到mySecondChangedHandler.SecondChanged=SomeMethod(...);/

c# - C# 'event' 关键字的多重含义?

我最近重新阅读了EricLippert的ridiculouslyawesome上的一些旧帖子博客并遇到thistidbit:AconsiderablefractionofthekeywordsofC#areusedintwoormoreways:fixed,into,partial,out,in,new,delegate,where,using,class,struct,true,false,base,this,event,returnandvoidallhaveatleasttwodifferentmeanings.为了好玩,我的同事和我自问自答,除了其中一个关键字之外,我能够为所有

c# - C# : generate a list of two dimension arrays with the same shape 中的 FsCheck

假设我正在编写一些视频分析代码。这是视频类的简化版本:publicclassVideo{publicreadonlyintWidth;publicreadonlyintHeight;publicreadonlyListFrames;publicVideo(intwidth,intheight,IEnumerableframes){Width=width;Height=height;Frames=newList();foreach(varframeinframes){if(frame.GetLength(0)!=height||frame.GetLength(1)!=width){thr

c# - 没有参数的 Event 应该定义自己的自定义 EventArgs 还是简单地使用 System.EventArgs?

我有一个当前定义的没有事件参数的事件。即它发送的EventArgs是EventArgs.Empty。在这种情况下,最简单的方法是将我的事件处理程序声明为:EventHandlerMyCustomEvent;我不打算向该事件添加任何事件参数,但将来可能需要更改任何代码。因此,我倾向于让我的所有事件始终创建一个从System.EventArgs继承的空事件参数类型,即使当前不需要事件参数。像这样:publicclassMyCustomEventArgs:EventArgs{}然后我的事件定义变成如下:EventHandlerMyCustomEvent;所以我的问题是:定义我自己的MyCus

c# - cs0030 :Unable to generate a temporary class

我有一个Web服务,当我尝试生成它的对象时出现以下错误。"Unabletogenerateatemporaryclass(result=1).errorCS0030:Cannotconverttype'ShortSell.ShortSellRQOriginDestinationInformationFlightSegment[]'to'ShortSell.ShortSellRQOriginDestinationInformationFlightSegment'errorCS0030:Cannotconverttype'ShortSell.ShortSellRSOriginDestina

c# - ASP.NET : Check for click event in page_load

在C#中,如何检查是否在页面加载方法中单击了链接按钮?我需要知道在触发点击事件之前它是否被点击。 最佳答案 if(IsPostBack){//getthetargetofthepost-back,willbethenameofthecontrol//thatissuedthepost-backstringeTarget=Request.Params["__EVENTTARGET"].ToString();} 关于c#-ASP.NET:Checkforclickeventinpage_lo

c# - 自定义工具错误 : Failed to generate file

我正在开发一个在VS2012(Framework4.5)windows窗体中创建的windows应用程序(C#)。要求要求它用于旧版本的Windows,因此我将目标框架设置为.NETFramework4并将平台目标设置为x86。一旦完成并尝试编译,我会收到以下错误:Customtoolerror:Failedtogeneratefile:Theservicereferenceisnotvalidforthecurrent.NETFrameworkversionorprojecttype.Youcanchangetheservicereferenceconfigurationinthe.

c# - IOC : Wiring up dependencies on event handlers

我正在构建一个WinForms应用程序,其UI仅包含NotifyIcon及其动态填充的ContextMenuStrip。有一个MainForm将应用程序保存在一起,但它永远不可见。我开始尽可能可靠地构建它(使用Autofac处理对象图)并且对我的成功非常满意,即使与O部分也相处得很好。通过我目前正在实现的扩展,我似乎发现了我的设计中的一个缺陷,需要稍微改造一下;我想知道我需要走的路,但对于如何准确定义依赖关系有点不清楚。如上所述,菜单在启动应用程序后部分动态填充。为此,我定义了一个IToolStripPopulator接口(interface):publicinterfaceITool