Tag: 实例

c#中类实例的内存使用情况

可能重复: C#/ .NET对象使用多少内存? 就像标题所说的那样,如何在c#(webforms)中检查类实例占用内存的内存量

如何使用SMO创建本地数据库实例

我已经安装了localdatabase并创建了一个共享实例,并且使用smo我可以创建localdatabase。 根据我的要求,我必须创建一个localdb共享实例。 我正在使用像这样的SMO创建本地数据库。 ServerConnection serConn = new ServerConnection(@”(localdb)\.\sharedIns”); Server ldbServer = new Server(serConn); Database db = new Database(ldbServer , “databaseName”); db.Create(); 在创建数据库之前,我使用sqllocaldb.exe通过命令提示符创建共享实例 c:\>sqllocaldb create testIns c:\>sqllocaldb share testIn sharedIns 我想删除这些手动步骤并使用SMO创建localdb共享实例。 这该怎么做?

如何与许多类共享一个类的实例?

我有ac #web服务。 当我收到新请求时,我创建了一个日志记录实例。 我有许多其他类的其他实例来处理请求,我也希望它们也能记录。 共享日志记录实例而不在构造函数或属性中传递它的最佳方法是什么?

GC.KeepAlive()当这个被取消注释时,仍然只有一个实例,怎么样?

反对下面的引用线程,即使我注释GC.KeepAlive(),我发现没有区别,它阻止了任何其他实例的创建。 为什么作者明确提到了它的重要路线? 确保只有一个应用程序实例

将两个富文本框滚动在一起,我无法弄明白

我想滚动聊天框时向上滚动时间框。 (不一定反之亦然) 我找到了以下代码: /// Subclass RichTextBox to add the capability to bind scrolling for multiple RichTextBoxs. /// This is useful for ‘parallel’ RTBs that require synchronized scrolling. /// Taken from https://gist.github.com/593809 /// Added WM_HSCROLL /// Added BindScroll() to form a two-way linkage between RichTextBoxes. /// Example usage showing how to bind 3 RichTextBoxes together: /// […]

c#类引用而不是实例引用

我可以在本地引用C#中的类,而不是类的实例吗? 以下代码不会编译,但作为示例,例如: void someFunc() { var a = System.Math; var b = a.Abs(4); } 编辑:在真正的程序中,它不是System.Math类,我想构造类并返回构造的值。 我最初并不认为我想要使用该类的上下文是相关的,而且可能不应该。 Anastasiosyal有一个有趣的想法,使用当地的代表来做。

对象引用未设置为对象的实例 – webservices

我有这个错误出现在我的Web服务中,即使我看过有关null问题的文章,我也无法找到如何修复此错误 这是我的代码: SendInvUpdate.InvServices.UpdateRatePackagesRequest urq = new SendInvUpdate.InvServices.UpdateRatePackagesRequest(); SendInvUpdate.InvServices.UpdateRatePackagesOperationResponse ors = new SendInvUpdate.InvServices.UpdateRatePackagesOperationResponse(); protected void Page_Load(object sender, EventArgs e) { Int64 HID = 819942; Int64 HRID = 154482; SendInvUpdate.InvServices.UpdateRatePackagesRequest request = new SendInvUpdate.InvServices.UpdateRatePackagesRequest(); ChannelManagerAccount account = new ChannelManagerAccount(); request.HotelId = HID; int avail = 4; DateTime frodte = Convert.ToDateTime(“2012-04-12”); DateTime todte = Convert.ToDateTime(“2012-04-30”); int NoofRatePackages = […]

Visual C#中的“全局变量”

我已经制作了Graph类,我想模拟一个分发网络。 图表100%工作。 但是,我想在我的所有应用程序中使用相同的结构/类! 例如:我有Form1显示模拟,但我想插入节点(例如)但我想在Form2中执行它! 由于数据总是在同一个类中,我可以使我的Graph实例全局,但C#不接受全局变量。 那么,我该如何解决这个问题呢? 有任何想法吗? 谢谢!

我无法访问光标的位置(以编程方式移动鼠标)

这是我的代码: private void MoveCursor(int x, int y) { // Set the Current cursor, move the cursor’s Position, // and set its clipping rectangle to the form. System.Windows.Forms.Cursor cursorMouse = new System.Windows.Forms.Cursor(System.Windows.Forms.Cursor.Current.Handle); cursorMouse.Position = new System.Drawing.Point(x, y); System.Windows.Forms.Cursor.Clip = new System.Drawing.Rectangle(cursorMouse.Position, cursorMouse.Size); } 这就是我的控制台所说的: Error 11 Member ‘System.Windows.Forms.Cursor.Position.get’ cannot be accessed with an instance reference; qualify […]

从string创建类实例

我有一个C#方法,它从字符串创建一个类的新实例,但是,在运行代码时出现错误。 obj = (ClassX)Activator.CreateInstance(Type.GetType(“classPrefix_” + className)); ArgumentNullException未处理 值不能为空 参数名称: 类型 任何有关此错误的帮助将不胜感激。