这句话Inherits System.Windows.Forms.Form什么时候必须要,什么时候可以省略?
这句话Inherits System.Windows.Forms.Form什么时候必须要,什么时候可以省略?
它的作用是什么?百度里这样的回答,正确吗???
继承 System.Windows.Forms.Form
.Net里,有很多命名空间
System是最大的一个
Windows是system里的一个子空间
依此类推
用了上面的语句,你的一些对象的方法,就可以不写全了,直接到上面的这个命令空间里找
功能有点类似于VB6中的 With结构
[解决办法]
Public Class Form1:Inherits System.WinForms.Form
没见过这种写法。C#使用冒号,VB使用Inherits。
[解决办法]
Imports System.Windows.Forms
Public Class Form1
Inherits System.WinForms.Form
End Class
因为使用了System.Windows.Forms,所以下面可以省略:
Imports System.Windows.Forms
Public Class Form1
Inherits Form
End Class
什么时候不用Inherits System.WinForms.Form
很简单,你不想让一个类从Form继承。
[解决办法]
这是命名空间,不是类。
我觉得你应该系统的学习下,因为你一点概念都没有一样。