草庐IT

stream_socket_get_name

全部标签

c# - 如何使用 { get; 访问私有(private)变量放; }

我想为我的网站创建一个包含大量私有(private)变量的类。我认为有一个解决方案可以不为每个变量编写所有的getter和setter,比如privateintconfirmed{get;set;}这是正确的方法吗?然后,我如何从类外访问这个值?我试过.confirmed,我收到错误消息说它是私有(private)的(据我所知)但更令人惊讶的是,.getConfirmed()或getconfirmed()也不起作用。我认为{get;放;会隐式地创建这些方法。有人可以为我澄清这个问题吗? 最佳答案 您可以将您的属性声明为公共(publ

c# - 是否有用于指定属性的 "display name"的 .NET 属性?

是否有允许您为类中的属性指定用户友好名称的属性?例如,假设我有以下类(class):publicclassPosition{publicstringEmployeeName{get;set;}publicContactInfoEmployeeContactInfo{get;set;}}我想指定EmployeeName属性的显示名称是“员工姓名”,EmployeeContactInfo属性的显示名称是“员工联系信息”.编写我自己的允许我这样做的属性类非常容易:[PropertyDisplayInfo(DisplayName="EmployeeName")]publicstringEmpl

c# - 将 Keith Hill 的 PowerShell Get-Clipboard 和 Set-Clipboard 转换为 PSM1 脚本

我想将KeithHill的Get-Clipboard和Set-Clipboard的C#实现转换为纯PowerShell作为.PSM1文件。有没有办法像他在使用剪贴板时在Cmdlet中所做的那样在PowerShell中启动STA线程?TheBlogPostTheCode 最佳答案 TextBox不需要-STA开关。functionGet-ClipBoard{Add-Type-AssemblyNameSystem.Windows.Forms$tb=New-ObjectSystem.Windows.Forms.TextBox$tb.Mul

c# - 如何覆盖 Razor 的 "name"HtmlAttribute

@Html.RadioButtonFor(Model=>Model.Location,"Location")@Html.LabelFor(Model=>Model.Location,"Location")@Html.RadioButtonFor(Model=>Model.Model,"Model")@Html.LabelFor(Model=>Model.Model,"Model")@Html.RadioButtonFor(Model=>Model.MovableUnit,"MU")@Html.LabelFor(Model=>Model.MovableUnit,"MU")Location

c# - SQLException (0x80131904) : Invalid object name 'dbo.Categories'

我在运行应用程序时遇到上述异常。该应用程序正在使用asp.netmvc3/C#。我制作了一个mdf文件并将其添加到VisualWebDeveloperExpress的App_Data文件夹下。我将连接字符串添加到web.config文件夹,但是当我运行并浏览到/store时,我收到上面的错误,并突出显示varcategories=storeDB.Categories.ToList();行。我的数据库包含6个表,其中一个是类别。Controller:EventCalendarEntitiesstoreDB=newEventCalendarEntities();publicActionRe

c# - "value cannot be null parameter name: key"

我在调试我正在处理的网站时遇到“蓝屏死机”。错误信息是“valuecannotbenull.Parametername:key.”我正在尝试将formview绑定(bind)到gridview的选定索引。当我在我的selectedindexchanged方法中设置断点时,一切似乎都正确绑定(bind),我可以查看我的formview的值,但是当我继续运行它时,我收到上述错误消息。我尝试将datakeynames属性添加到formview并得到相同的错误消息。我在这里和谷歌搜索并看到了一些结果,但似乎没有一个能解决或与我的问题相关。部分代码如下:protectedvoidGridView

c# - EF 5 代码迁移错误 : "There is already an object named _____ in the database"

在进行EF5代码迁移时遇到了一个反复出现的奇怪问题,现在让我无法工作。尝试运行update-database并收到此错误:Thereisalreadyanobjectnamed'RequestStatus'inthedatabase.详细的日志转储:PM>update-database-vUsingStartUpproject'LicensingWorkflow'.UsingNuGetproject'LicensingWorkflow'.Specifythe'-Verbose'flagtoviewtheSQLstatementsbeingappliedtothetargetdataba

c# - 程序退出后 TcpListener Socket 仍然有效

我正试图在我的程序退出时停止TCP监听器。我不关心套接字或任何事件客户端套接字上当前事件的任何数据。套接字清理代码本质上是:try{myServer.Server.Shutdown(SocketShutdown.Both)}catch(Exceptionex){LogException(ex)}myServer.Server.Close(0)myServer.Stop()myServer是一个TCPListener在某些情况下,Shutdown会抛出异常System.Net.Sockets.SocketException:发送或接收数据的请求被禁止,因为套接字未连接并且(当使用send

c# - 取消 Socket.xxxxAsync 调用

调用Socket.Shutdown、Socket.Close和Socket.Disconnect后,Socket.ReceiveAsync似乎没有中止。尝试重用ReceiveAsync调用中使用的SocketAsycEventArgs对象(在文档中作为最佳实践建议)会导致错误:AnasynchronoussocketoperationisalreadyinprogressusingthisSocketAsyncEventArgsinstance我必须做什么才能让ReceiveAsync释放它对这个SocketAsyncEventArgs实例的控制?编辑:我通过标记一个待处理的接收并且在

C# 正则表达式 : Named Group Valid Characters?

什么是有效的组名?varre=newRegex(@"(?pattern)"); 最佳答案 简答允许的字符是[a-zA-Z0-9_]长答案根据Microsoftdocs:namemustnotcontainanypunctuationcharactersandcannotbeginwithanumber.不过说的不是很具体,还是看源码吧:sourcecodefortheclassSystem.Text.RegularExpressions.RegexParser向我们展示了允许的字符本质上是[a-zA-Z0-9_]。确切地说,在用于检