Generic Class's Constructors With Param
Dec 30, 2009
i've got a Class like this public Class Cart(Of Item) Public Sub New(ByVal a As Integer, ByVal ParamArray items As Item())but i do not see how to create an instance of it: Dim block_names As New Cart(Of String, 5I)i get something like "type expected" o.O
View 2 Replies
ADVERTISEMENT
Dec 14, 2006
I have the following VB.NET function, for example:Public Function MyFunction (Of TData) (ByVal InParam As Integer) As TDataEnd Sub
View 5 Replies
Jan 21, 2010
I can do this without problem.
Class A
End Class
Class B : Inherit A
End Class
Dim Obj1 As A = New B
View 4 Replies
Apr 19, 2009
1)When we use Overload constructors in a class
2)and which one is get execut first.
Public Class remoteobj
[Code]...
View 4 Replies
Apr 13, 2012
Consider:
Public MustInherit Class Column
Public ReadOnly Property ReturnSomethingUseful() As Object
Get
'return something useful
[code]....
But this gives the following error:
Public Overrides Function ParseValue(sValue As String) As Boolean'
cannot override 'Public Overridable Function ParseValue(sValue As String) As Object'
because they differ by their return types.
I accept that you can't do this, but I'd like to be able to preserve the semantics of what I'm. trying to do, which is to have an untyped version that deals with Object, but a typed version in derived classes that knows about the specific type T.
View 2 Replies
Jul 5, 2009
What is the difference between a class with protected constructors and a class marked as MustInherit? (I'm programming in VB.Net but it probably equally applies to c#). The reason I ask is because I have an abstract class that I want to convert the constructors to shared/static methods. (To add some constraints). I can't do this because it's not possible to create an instance in the shared function.
[Code]...
View 3 Replies
Aug 14, 2010
I have a Journal that records entries for different types: Journal(Of ParentT)
[Code]....
View 2 Replies
Nov 25, 2011
I am trying to construct a generic interface class with generic functions. My goal was to use this to implement multiple worker classes for database interaction that have the same basic functionality. Each class will deal with different object for example, category, product or supplier but unless the the functions in the interface are generic that this won't work.This is the interface code that I have but I don't know if I have done it correctly. [code]
View 2 Replies
Jan 12, 2010
Most of our code base is in VB.NET. I'm developing a project in C# that uses a lot of the assemblies from the VB.NET code.There are three relevant classes in VB.NET:
[Code]...
View 3 Replies
Feb 16, 2012
I'm trying to create a class for storing data on People with another class to store their Bank Transactions.Ideally, this all be hidden away and leave only simple statments, declarations and functions available to the programmer.[code]I know this is possible as these exist in the Listbox Class though can't figure out how it's done.
View 2 Replies
Apr 7, 2011
Imports System
Imports System.Threading
Imports System.ComponentModel[code]....
how to declare "smsport" on class smscomms as public so that it can be access in class form1 or button1_click event.
View 5 Replies
Feb 19, 2010
I am working on a general helper class to sort ListView SubItems. I wrote a base class that has much of the code I need. It includes a MustOverride for the Compare method so that the various inherited classes can implment their own comparisons based upon their type. For the value types, I end up with very similar code such as the following, where x and y are ListViewItems: Public Overloads Overrides Function Compare(ByVal x As Object, ByVal y As Object, ByVal sortColumnIndex As Integer, ByVal sortOrder As System.Windows.Forms.SortOrder) As Integer [code]
View 3 Replies
Oct 23, 2009
In c# you can have
public class Foo
{
public Foo(string name)
{
//do something
[Code]...
Is there a VB.Net equivalent?
View 1 Replies
Apr 22, 2009
I need to have a dynamic URL preferably from a Test Classformatting this design pattern to handle dynamic links from tests. instead of a constant HomePageURL.
Namespace TestDesign
Public Class HomePage
Inherits IE
[code].....
View 1 Replies
Mar 19, 2010
How can I recognize (.NET 2) a generic class?
Class A(Of T)
End Class
' not work '
If TypeOf myObject Is A Then
View 2 Replies
Apr 29, 2009
I have the following sample code in a VB.NET console application. It compiles and works, but feels like a hack. Is there a way to define EmptyChild so that it inherits from Intermediate(Of T As Class) without using the dummy EmptyClass?
Module Module1
Sub Main()
Dim Child1 = New RealChild()[code].....
The other way to do this would be to move the generic code out of the Base class and then create 2 Intermediate classes like this [code]...
Then RealChild would inherit from the generic Intermediate and EmptyChild would inherit from the non-generic Intermediate. My problem with that solution is that the Base class is in a separate assembly and I need to keep the code that handles the generic type in that assembly. And there is functionality in the Intermediate class that does not belong in the assembly with the Base class.
View 1 Replies
May 10, 2010
I created two classes. One class is StudentClass and the other is HomeroomClass. The HomeroomClass contains a readonly property as a generic list of the StudentClass. [code]...
View 6 Replies
Apr 28, 2010
I am really trying to follow the DRY principle. I have a sub that looks like this?
Private Sub DoSupplyModel
OutputLine("ITEM SUMMARIES")
Dim ItemSumms As New SupplyModel.ItemSummaries(_currentSupplyModel, _excelRows)
ItemSumms.FillRows()
[Code]...
View 4 Replies
Jan 1, 2011
Here are essential excerpts for the code creating the class and the page using it:
Imports System.Collections.ObjectModel
Public Class Test (Of T as xyz)
Inherits Collection (Of T)
[code].....
View 7 Replies
Jan 10, 2012
We are developing an application for our shop floor. This program will be tracking material through the shop and we need to capture any errors the program generates, but we don't need to stop the program for all errors. I have some code to do a screen capture and put it in a database with exception.tostring data for debugging.
What we would like to do, is create an exception from the base class, but provide additional properties to allow us to set a severity and a user friendly error message. I would like to encapsulate this in a class that we would call in the catch of a try/catch, set the properties on the class, have the class record the data to the database, then raise the exception to the main program to display only the user friendly message and severity. The main program would then determine the severity and based on the severity stop the program or just display a discreet msg and continue to process.
Does anyone have an example of a custom exception class derived from exception that does something similar, or if I heading in the wrong direction, does anyone have a better solution?
View 5 Replies
Jan 11, 2010
I'm having trouble with the definition of an inherited generic class. I have two base classes that are defined like this:[code]
View 2 Replies
Jun 10, 2010
how Inheriting List(of T) should work.It seems like what I have below should work but at runtime I get the error:[code..]
If I want to cast a List(of x) to the class xlist, how should I do that?[code...]
View 15 Replies
Jul 15, 2010
ok this is the thing I have right now which is working quite well beside its a bit slow:
Public Function GetList() As List(Of SalesOrder)
Try
Dim list As New List(Of SalesOrder)
Dim ds As DataSet
ds = cls.GetSalesOrderList 'CLS is the data access class
[Code]...
View 2 Replies
Jun 17, 2012
I am trying to create a class implementing the generic IComparer of my own class "Stellungen" (which translates to positions, like on a chess or checkers board).
This is what I got:
Private Class comparer(Of Stellung)
Implements System.Collections.Generic.IComparer(Of Stellung)
Public Function Compare(x As Stellung, y As Stellung) As Integer Implements System.Collections.Generic.IComparer(Of Stellung).Compare
End Function
End Class
Problem is: inside the function I have no access to any fields of my class. If I start off with x. Intellisense will only give me .Equals, .GetHashCode - the methods you get on a type but not on an instance. Visual Studio 10 also highlights this, in the definition of the function the bits "x as Stellung" and "y as Stellung" are written in light blue, meaning it is a type and not an actual object. How do I access the things I want to compare inside my class?
View 1 Replies
Jun 26, 2009
I am creating a generic class that is Implementing IList(Of T) which requires that I implement the GetEnumorator of both IEnumerable(Of T) and IEnumerable. When looking at the members of IList(Of T) I see only one GetEnumorator function, yet it implements IEnumerable(Of T) and IEnumerable. How can I use one function to implement both interfaces when the function definitions only vary by return type?
View 8 Replies
Jul 20, 2010
Public Function GetList() As List(Of SalesOrder)
Try
Dim list As New List(Of SalesOrder)
Dim ds As DataSet
[code]....
Now once I start retrieving more than 10000 records from the table, the loop takes long time to load values into generic class. Is there any way that I can get rid of loop? Can I do something like the following with the generic class?
txtSearch.AutoCompleteCustomSource.AddRange(Array. ConvertAll(Of DataRow, String)(BusinessLogic.ToDataTable.ConvertTo(WorkOr derList).Select(), Function(row As DataRow) row("TradeContactName")))
View 3 Replies
Oct 7, 2010
I am trying to serialize a class that contains a generic list, and I am finding it all works with the exception of the generic list property. That is to say the other properties are serialized fine and no error is produced.
I have in the past serialized an arraylist - but I thought it was possible to do a generic list in the same way.
Am I missing something or is it not possible to serialize/deserialize a generic list - I have read mixed comments on this..
The relevant parts of the class that gets serialized is defined as..
<XmlInclude(GetType(cConfigUser)), _
Serializable(), XmlRoot(ElementName:="Config")> _
Public Class cConfig
[Code].....
View 3 Replies
Jan 28, 2010
I have created a Interface and a couple classes that implement this Interface. I am in the process of developing a Shared Class that utilizes the functions that each of the individual classes have, due to the interface implementation.What i need to know is how do i develop this Shared Class so that way each of the methods within it are restricted to a single data type. This single data type needs to be restricted to any class that has implemented the Interface.
Some examples:
Public Interface IVector(Of T)
Sub Add(ByVal v2 as T)
[code]....
As you can see it would allow me to develop one form, since i have standardized the required Subs/Functions for any class the implements the IVector interface. As i am still in developement, i was wondering if my current understanding of the method generics is correct in its current form or what i would have to do to make the Generic Shared Class work in the fashion that i am looking for in the example implementation.
View 6 Replies
May 29, 2010
I have a routine that accepts a List of Objects, a property name and a value to search for and simply returns whether or not it found it.The code I have hangs up at the For loop in the findit routine.[code]
View 4 Replies
Sep 27, 2011
i've got a generic class for xml serialization and deserialization.
Public Class clsXMLHandler(Of T)
Public Sub serializeFromObject(ByVal filePath As String, ByVal [object] As T)
Dim creater As New FileStream(filePath, FileMode.Create)
Dim xml As New XmlSerializer([object].GetType)
xml.Serialize(creater, [object])
[Code]...
View 1 Replies