How To MustOverride Shared/Constructor Function Visual Basic
I'm currently using Visual Basic for a College Project which requires us to make a simple database system. For my system I have a base(abstract) class called Record
which is inherited by the different types of records there are in my database e.g. Member
, User
, Role
.
I am saving my data in csv files and have already written a CSVHandler
class. However, I want an elegant way of constructing an instance of a class derived from Record
with a string from the CSVHandler
.
This is where the problem occurs. The only way I can think of doing this is by making a Constrcutor
or Shared Function
in each class derived from Record
. However, Visual Basic does not allow you make Constructors
or Shared Functions
also MustOverride
.
Here is the code I would expect to write:
' Base Class
Public MustInherit Class Record
Public MustOverride Shared Function fromString(ByVal str as String) As Record
End Class
' Example Of Class Derived From Record
Public Class User
Inherits Record
Private _id As String
Private _name As String
Public Sub New(ByVal id As String, ByVal name As String)
_id = id
_name = name
End Sub
Public Overrides Shared Function fromString(ByVal str as String) As Record
Dim strs() As String = str.Split(",")
Return New User(strs(0), strs(1))
End Function
End Class
' Example Of Creating Instacnce Of User
Dim user1 = User.fromString("1671,Kappeh")
Is there a way to achieve this effect?
Thanks in advanced for the help :)
database vb.net inheritance constructor shared
add a comment |
I'm currently using Visual Basic for a College Project which requires us to make a simple database system. For my system I have a base(abstract) class called Record
which is inherited by the different types of records there are in my database e.g. Member
, User
, Role
.
I am saving my data in csv files and have already written a CSVHandler
class. However, I want an elegant way of constructing an instance of a class derived from Record
with a string from the CSVHandler
.
This is where the problem occurs. The only way I can think of doing this is by making a Constrcutor
or Shared Function
in each class derived from Record
. However, Visual Basic does not allow you make Constructors
or Shared Functions
also MustOverride
.
Here is the code I would expect to write:
' Base Class
Public MustInherit Class Record
Public MustOverride Shared Function fromString(ByVal str as String) As Record
End Class
' Example Of Class Derived From Record
Public Class User
Inherits Record
Private _id As String
Private _name As String
Public Sub New(ByVal id As String, ByVal name As String)
_id = id
_name = name
End Sub
Public Overrides Shared Function fromString(ByVal str as String) As Record
Dim strs() As String = str.Split(",")
Return New User(strs(0), strs(1))
End Function
End Class
' Example Of Creating Instacnce Of User
Dim user1 = User.fromString("1671,Kappeh")
Is there a way to achieve this effect?
Thanks in advanced for the help :)
database vb.net inheritance constructor shared
1
Unfortunately, there is no way in .NET to enforce the existence of aShared
Sub
orFunction
. I've felt the lack before. In one case, it's a factory method, and since I'm already using reflection to implement the factory, I just require theShared
member to be provided by convention (and get it via reflection). In another case, a routine that logically should be shared ends up being a member function just so that I can require it to be present on a generic argument.
– Craig
Nov 21 '18 at 15:32
1
Why would your college ask you to write a database application without a database?
– Mary
Nov 21 '18 at 22:30
add a comment |
I'm currently using Visual Basic for a College Project which requires us to make a simple database system. For my system I have a base(abstract) class called Record
which is inherited by the different types of records there are in my database e.g. Member
, User
, Role
.
I am saving my data in csv files and have already written a CSVHandler
class. However, I want an elegant way of constructing an instance of a class derived from Record
with a string from the CSVHandler
.
This is where the problem occurs. The only way I can think of doing this is by making a Constrcutor
or Shared Function
in each class derived from Record
. However, Visual Basic does not allow you make Constructors
or Shared Functions
also MustOverride
.
Here is the code I would expect to write:
' Base Class
Public MustInherit Class Record
Public MustOverride Shared Function fromString(ByVal str as String) As Record
End Class
' Example Of Class Derived From Record
Public Class User
Inherits Record
Private _id As String
Private _name As String
Public Sub New(ByVal id As String, ByVal name As String)
_id = id
_name = name
End Sub
Public Overrides Shared Function fromString(ByVal str as String) As Record
Dim strs() As String = str.Split(",")
Return New User(strs(0), strs(1))
End Function
End Class
' Example Of Creating Instacnce Of User
Dim user1 = User.fromString("1671,Kappeh")
Is there a way to achieve this effect?
Thanks in advanced for the help :)
database vb.net inheritance constructor shared
I'm currently using Visual Basic for a College Project which requires us to make a simple database system. For my system I have a base(abstract) class called Record
which is inherited by the different types of records there are in my database e.g. Member
, User
, Role
.
I am saving my data in csv files and have already written a CSVHandler
class. However, I want an elegant way of constructing an instance of a class derived from Record
with a string from the CSVHandler
.
This is where the problem occurs. The only way I can think of doing this is by making a Constrcutor
or Shared Function
in each class derived from Record
. However, Visual Basic does not allow you make Constructors
or Shared Functions
also MustOverride
.
Here is the code I would expect to write:
' Base Class
Public MustInherit Class Record
Public MustOverride Shared Function fromString(ByVal str as String) As Record
End Class
' Example Of Class Derived From Record
Public Class User
Inherits Record
Private _id As String
Private _name As String
Public Sub New(ByVal id As String, ByVal name As String)
_id = id
_name = name
End Sub
Public Overrides Shared Function fromString(ByVal str as String) As Record
Dim strs() As String = str.Split(",")
Return New User(strs(0), strs(1))
End Function
End Class
' Example Of Creating Instacnce Of User
Dim user1 = User.fromString("1671,Kappeh")
Is there a way to achieve this effect?
Thanks in advanced for the help :)
database vb.net inheritance constructor shared
database vb.net inheritance constructor shared
edited Nov 21 '18 at 16:44
Kieran Powell
asked Nov 21 '18 at 2:34
Kieran PowellKieran Powell
305
305
1
Unfortunately, there is no way in .NET to enforce the existence of aShared
Sub
orFunction
. I've felt the lack before. In one case, it's a factory method, and since I'm already using reflection to implement the factory, I just require theShared
member to be provided by convention (and get it via reflection). In another case, a routine that logically should be shared ends up being a member function just so that I can require it to be present on a generic argument.
– Craig
Nov 21 '18 at 15:32
1
Why would your college ask you to write a database application without a database?
– Mary
Nov 21 '18 at 22:30
add a comment |
1
Unfortunately, there is no way in .NET to enforce the existence of aShared
Sub
orFunction
. I've felt the lack before. In one case, it's a factory method, and since I'm already using reflection to implement the factory, I just require theShared
member to be provided by convention (and get it via reflection). In another case, a routine that logically should be shared ends up being a member function just so that I can require it to be present on a generic argument.
– Craig
Nov 21 '18 at 15:32
1
Why would your college ask you to write a database application without a database?
– Mary
Nov 21 '18 at 22:30
1
1
Unfortunately, there is no way in .NET to enforce the existence of a
Shared
Sub
or Function
. I've felt the lack before. In one case, it's a factory method, and since I'm already using reflection to implement the factory, I just require the Shared
member to be provided by convention (and get it via reflection). In another case, a routine that logically should be shared ends up being a member function just so that I can require it to be present on a generic argument.– Craig
Nov 21 '18 at 15:32
Unfortunately, there is no way in .NET to enforce the existence of a
Shared
Sub
or Function
. I've felt the lack before. In one case, it's a factory method, and since I'm already using reflection to implement the factory, I just require the Shared
member to be provided by convention (and get it via reflection). In another case, a routine that logically should be shared ends up being a member function just so that I can require it to be present on a generic argument.– Craig
Nov 21 '18 at 15:32
1
1
Why would your college ask you to write a database application without a database?
– Mary
Nov 21 '18 at 22:30
Why would your college ask you to write a database application without a database?
– Mary
Nov 21 '18 at 22:30
add a comment |
2 Answers
2
active
oldest
votes
The following is similar to the answer from @jmcilhinney in that it forces the derived class to implement an initialization method. However it makes use of a generic shared function and uses the little known GetUninitializedObject method to get around using the generic New
constraint and it's requirement of an accessible parameter-less constructor.
Public MustInherit Class Record
Public Shared Function fromString(Of T As {Record})(ByVal str As String) As T
' create an unintialized instance of T
Dim ret As T = DirectCast(System.Runtime.Serialization.FormatterServices.GetUninitializedObject(GetType(T)), T)
ret.Initialize(str)
Return ret
End Function
Protected MustOverride Sub Initialize(source As String)
End Class
The User
class then would be something like this:
Public Class User : Inherits Record
Private _id As String
Private _name As String
Public Sub New(ByVal id As String, ByVal name As String)
_id = id
_name = name
End Sub
Protected Overrides Sub Initialize(source As String)
Dim strs() As String = source.Split(","c)
_id = strs(0)
_name = strs(1)
End Sub
End Class
Example usage:
Dim userRecord As User = Record.fromString(Of User)("1,2")
I do like this solution. Although I have a working code, I may give this approach a shot as it is more elegant than mine. It also ties in well with how some of my other code works. Thank you very much :)
– Kieran Powell
Nov 21 '18 at 14:04
add a comment |
Have your constructor call a Protected MustOverride
method that does the initialisation.
Public MustInherit Class Record
'This is required because each derived constructor must be able to implicitly invoke a parameterless
'base constructor if it doesn't explicitly invoke a base constructor with parameters.
Protected Sub New()
End Sub
Public Sub New(csv As String)
Init(csv)
End Sub
Protected MustOverride Sub Init(csv As String)
End Class
Public Class User
Inherits Record
Private Property Id As String
Private Property Name As String
'This is still required because you can use a base constructor directly to create a derived instance.
Public Sub New(csv As String)
MyBase.New(csv)
End Sub
Public Sub New(id As String, name As String)
Id = id
Name = name
End Sub
Protected Overrides Sub Init(csv As String)
'Add your type-specific implementation here.
End Sub
End Class
This "solution" doesn't actually do what I thought it would because, while it forces you to override Init
in a derived class, you still have to provide a derived constructor that invokes the base constructor that calls Init
and you still can't enforce that. I think that I'll leave this as an answer though, because, while it doesn't actually provide a solution to your problem, it demonstrates further why (as far as I can tell) there is no such solution.
Thanks for your time and help. I think what I will do is make aMustOverride Sub
likesetFromString(ByVal str As String)
Which I can use after the instance of the object has been created. It seems to be the only way I can think of to make it enforced.
– Kieran Powell
Nov 21 '18 at 3:50
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53404542%2fhow-to-mustoverride-shared-constructor-function-visual-basic%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The following is similar to the answer from @jmcilhinney in that it forces the derived class to implement an initialization method. However it makes use of a generic shared function and uses the little known GetUninitializedObject method to get around using the generic New
constraint and it's requirement of an accessible parameter-less constructor.
Public MustInherit Class Record
Public Shared Function fromString(Of T As {Record})(ByVal str As String) As T
' create an unintialized instance of T
Dim ret As T = DirectCast(System.Runtime.Serialization.FormatterServices.GetUninitializedObject(GetType(T)), T)
ret.Initialize(str)
Return ret
End Function
Protected MustOverride Sub Initialize(source As String)
End Class
The User
class then would be something like this:
Public Class User : Inherits Record
Private _id As String
Private _name As String
Public Sub New(ByVal id As String, ByVal name As String)
_id = id
_name = name
End Sub
Protected Overrides Sub Initialize(source As String)
Dim strs() As String = source.Split(","c)
_id = strs(0)
_name = strs(1)
End Sub
End Class
Example usage:
Dim userRecord As User = Record.fromString(Of User)("1,2")
I do like this solution. Although I have a working code, I may give this approach a shot as it is more elegant than mine. It also ties in well with how some of my other code works. Thank you very much :)
– Kieran Powell
Nov 21 '18 at 14:04
add a comment |
The following is similar to the answer from @jmcilhinney in that it forces the derived class to implement an initialization method. However it makes use of a generic shared function and uses the little known GetUninitializedObject method to get around using the generic New
constraint and it's requirement of an accessible parameter-less constructor.
Public MustInherit Class Record
Public Shared Function fromString(Of T As {Record})(ByVal str As String) As T
' create an unintialized instance of T
Dim ret As T = DirectCast(System.Runtime.Serialization.FormatterServices.GetUninitializedObject(GetType(T)), T)
ret.Initialize(str)
Return ret
End Function
Protected MustOverride Sub Initialize(source As String)
End Class
The User
class then would be something like this:
Public Class User : Inherits Record
Private _id As String
Private _name As String
Public Sub New(ByVal id As String, ByVal name As String)
_id = id
_name = name
End Sub
Protected Overrides Sub Initialize(source As String)
Dim strs() As String = source.Split(","c)
_id = strs(0)
_name = strs(1)
End Sub
End Class
Example usage:
Dim userRecord As User = Record.fromString(Of User)("1,2")
I do like this solution. Although I have a working code, I may give this approach a shot as it is more elegant than mine. It also ties in well with how some of my other code works. Thank you very much :)
– Kieran Powell
Nov 21 '18 at 14:04
add a comment |
The following is similar to the answer from @jmcilhinney in that it forces the derived class to implement an initialization method. However it makes use of a generic shared function and uses the little known GetUninitializedObject method to get around using the generic New
constraint and it's requirement of an accessible parameter-less constructor.
Public MustInherit Class Record
Public Shared Function fromString(Of T As {Record})(ByVal str As String) As T
' create an unintialized instance of T
Dim ret As T = DirectCast(System.Runtime.Serialization.FormatterServices.GetUninitializedObject(GetType(T)), T)
ret.Initialize(str)
Return ret
End Function
Protected MustOverride Sub Initialize(source As String)
End Class
The User
class then would be something like this:
Public Class User : Inherits Record
Private _id As String
Private _name As String
Public Sub New(ByVal id As String, ByVal name As String)
_id = id
_name = name
End Sub
Protected Overrides Sub Initialize(source As String)
Dim strs() As String = source.Split(","c)
_id = strs(0)
_name = strs(1)
End Sub
End Class
Example usage:
Dim userRecord As User = Record.fromString(Of User)("1,2")
The following is similar to the answer from @jmcilhinney in that it forces the derived class to implement an initialization method. However it makes use of a generic shared function and uses the little known GetUninitializedObject method to get around using the generic New
constraint and it's requirement of an accessible parameter-less constructor.
Public MustInherit Class Record
Public Shared Function fromString(Of T As {Record})(ByVal str As String) As T
' create an unintialized instance of T
Dim ret As T = DirectCast(System.Runtime.Serialization.FormatterServices.GetUninitializedObject(GetType(T)), T)
ret.Initialize(str)
Return ret
End Function
Protected MustOverride Sub Initialize(source As String)
End Class
The User
class then would be something like this:
Public Class User : Inherits Record
Private _id As String
Private _name As String
Public Sub New(ByVal id As String, ByVal name As String)
_id = id
_name = name
End Sub
Protected Overrides Sub Initialize(source As String)
Dim strs() As String = source.Split(","c)
_id = strs(0)
_name = strs(1)
End Sub
End Class
Example usage:
Dim userRecord As User = Record.fromString(Of User)("1,2")
answered Nov 21 '18 at 4:43
TnTinMnTnTinMn
6,32931027
6,32931027
I do like this solution. Although I have a working code, I may give this approach a shot as it is more elegant than mine. It also ties in well with how some of my other code works. Thank you very much :)
– Kieran Powell
Nov 21 '18 at 14:04
add a comment |
I do like this solution. Although I have a working code, I may give this approach a shot as it is more elegant than mine. It also ties in well with how some of my other code works. Thank you very much :)
– Kieran Powell
Nov 21 '18 at 14:04
I do like this solution. Although I have a working code, I may give this approach a shot as it is more elegant than mine. It also ties in well with how some of my other code works. Thank you very much :)
– Kieran Powell
Nov 21 '18 at 14:04
I do like this solution. Although I have a working code, I may give this approach a shot as it is more elegant than mine. It also ties in well with how some of my other code works. Thank you very much :)
– Kieran Powell
Nov 21 '18 at 14:04
add a comment |
Have your constructor call a Protected MustOverride
method that does the initialisation.
Public MustInherit Class Record
'This is required because each derived constructor must be able to implicitly invoke a parameterless
'base constructor if it doesn't explicitly invoke a base constructor with parameters.
Protected Sub New()
End Sub
Public Sub New(csv As String)
Init(csv)
End Sub
Protected MustOverride Sub Init(csv As String)
End Class
Public Class User
Inherits Record
Private Property Id As String
Private Property Name As String
'This is still required because you can use a base constructor directly to create a derived instance.
Public Sub New(csv As String)
MyBase.New(csv)
End Sub
Public Sub New(id As String, name As String)
Id = id
Name = name
End Sub
Protected Overrides Sub Init(csv As String)
'Add your type-specific implementation here.
End Sub
End Class
This "solution" doesn't actually do what I thought it would because, while it forces you to override Init
in a derived class, you still have to provide a derived constructor that invokes the base constructor that calls Init
and you still can't enforce that. I think that I'll leave this as an answer though, because, while it doesn't actually provide a solution to your problem, it demonstrates further why (as far as I can tell) there is no such solution.
Thanks for your time and help. I think what I will do is make aMustOverride Sub
likesetFromString(ByVal str As String)
Which I can use after the instance of the object has been created. It seems to be the only way I can think of to make it enforced.
– Kieran Powell
Nov 21 '18 at 3:50
add a comment |
Have your constructor call a Protected MustOverride
method that does the initialisation.
Public MustInherit Class Record
'This is required because each derived constructor must be able to implicitly invoke a parameterless
'base constructor if it doesn't explicitly invoke a base constructor with parameters.
Protected Sub New()
End Sub
Public Sub New(csv As String)
Init(csv)
End Sub
Protected MustOverride Sub Init(csv As String)
End Class
Public Class User
Inherits Record
Private Property Id As String
Private Property Name As String
'This is still required because you can use a base constructor directly to create a derived instance.
Public Sub New(csv As String)
MyBase.New(csv)
End Sub
Public Sub New(id As String, name As String)
Id = id
Name = name
End Sub
Protected Overrides Sub Init(csv As String)
'Add your type-specific implementation here.
End Sub
End Class
This "solution" doesn't actually do what I thought it would because, while it forces you to override Init
in a derived class, you still have to provide a derived constructor that invokes the base constructor that calls Init
and you still can't enforce that. I think that I'll leave this as an answer though, because, while it doesn't actually provide a solution to your problem, it demonstrates further why (as far as I can tell) there is no such solution.
Thanks for your time and help. I think what I will do is make aMustOverride Sub
likesetFromString(ByVal str As String)
Which I can use after the instance of the object has been created. It seems to be the only way I can think of to make it enforced.
– Kieran Powell
Nov 21 '18 at 3:50
add a comment |
Have your constructor call a Protected MustOverride
method that does the initialisation.
Public MustInherit Class Record
'This is required because each derived constructor must be able to implicitly invoke a parameterless
'base constructor if it doesn't explicitly invoke a base constructor with parameters.
Protected Sub New()
End Sub
Public Sub New(csv As String)
Init(csv)
End Sub
Protected MustOverride Sub Init(csv As String)
End Class
Public Class User
Inherits Record
Private Property Id As String
Private Property Name As String
'This is still required because you can use a base constructor directly to create a derived instance.
Public Sub New(csv As String)
MyBase.New(csv)
End Sub
Public Sub New(id As String, name As String)
Id = id
Name = name
End Sub
Protected Overrides Sub Init(csv As String)
'Add your type-specific implementation here.
End Sub
End Class
This "solution" doesn't actually do what I thought it would because, while it forces you to override Init
in a derived class, you still have to provide a derived constructor that invokes the base constructor that calls Init
and you still can't enforce that. I think that I'll leave this as an answer though, because, while it doesn't actually provide a solution to your problem, it demonstrates further why (as far as I can tell) there is no such solution.
Have your constructor call a Protected MustOverride
method that does the initialisation.
Public MustInherit Class Record
'This is required because each derived constructor must be able to implicitly invoke a parameterless
'base constructor if it doesn't explicitly invoke a base constructor with parameters.
Protected Sub New()
End Sub
Public Sub New(csv As String)
Init(csv)
End Sub
Protected MustOverride Sub Init(csv As String)
End Class
Public Class User
Inherits Record
Private Property Id As String
Private Property Name As String
'This is still required because you can use a base constructor directly to create a derived instance.
Public Sub New(csv As String)
MyBase.New(csv)
End Sub
Public Sub New(id As String, name As String)
Id = id
Name = name
End Sub
Protected Overrides Sub Init(csv As String)
'Add your type-specific implementation here.
End Sub
End Class
This "solution" doesn't actually do what I thought it would because, while it forces you to override Init
in a derived class, you still have to provide a derived constructor that invokes the base constructor that calls Init
and you still can't enforce that. I think that I'll leave this as an answer though, because, while it doesn't actually provide a solution to your problem, it demonstrates further why (as far as I can tell) there is no such solution.
edited Nov 21 '18 at 2:56
answered Nov 21 '18 at 2:43
jmcilhinneyjmcilhinney
25.7k22032
25.7k22032
Thanks for your time and help. I think what I will do is make aMustOverride Sub
likesetFromString(ByVal str As String)
Which I can use after the instance of the object has been created. It seems to be the only way I can think of to make it enforced.
– Kieran Powell
Nov 21 '18 at 3:50
add a comment |
Thanks for your time and help. I think what I will do is make aMustOverride Sub
likesetFromString(ByVal str As String)
Which I can use after the instance of the object has been created. It seems to be the only way I can think of to make it enforced.
– Kieran Powell
Nov 21 '18 at 3:50
Thanks for your time and help. I think what I will do is make a
MustOverride Sub
like setFromString(ByVal str As String)
Which I can use after the instance of the object has been created. It seems to be the only way I can think of to make it enforced.– Kieran Powell
Nov 21 '18 at 3:50
Thanks for your time and help. I think what I will do is make a
MustOverride Sub
like setFromString(ByVal str As String)
Which I can use after the instance of the object has been created. It seems to be the only way I can think of to make it enforced.– Kieran Powell
Nov 21 '18 at 3:50
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53404542%2fhow-to-mustoverride-shared-constructor-function-visual-basic%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Unfortunately, there is no way in .NET to enforce the existence of a
Shared
Sub
orFunction
. I've felt the lack before. In one case, it's a factory method, and since I'm already using reflection to implement the factory, I just require theShared
member to be provided by convention (and get it via reflection). In another case, a routine that logically should be shared ends up being a member function just so that I can require it to be present on a generic argument.– Craig
Nov 21 '18 at 15:32
1
Why would your college ask you to write a database application without a database?
– Mary
Nov 21 '18 at 22:30