.net - Use Generic Method To Replace Duplicated Properties?

Jul 29, 2011

Currently my code has the following properties:

[Code]...

View 3 Replies


ADVERTISEMENT

Can XML ID Properties Be Duplicated

Feb 2, 2009

this makes sense given the context of the document but I heard that XML tag's should have Unique ID's, which is fair enough but I was under the impression that each child node does not know about other child nodes outside its parent? What is your thought on this?

HTML

<?xml version="1.0" encoding="utf-8"?>
<main>
<SourceType ID="XAML">

[Code]...

View 3 Replies

Multithreading - Modify A Generic Invoke Method To A Generic BeginInvoke Method?

Oct 7, 2010

I have been using a pretty slick generic invoke method for UI updating from background threads. I forget where I copied it from (converted it to VB.NET from C#), but here it is: Public Sub InvokeControl(Of T As Control)(ByVal Control As t, ByVal Action As Action(Of t))

[Code]....

View 1 Replies

Strongly-typed Generic Method Invokes Its Argument's Base Class Method Instead Of A Shadowed Method In T?

Oct 19, 2010

Consider a MyForm class that contains a shadowed implementation of Show(). It also contains a CreateForm() method, which accepts an instance of the form and calls the shadowed sub:

[Code]....

View 3 Replies

.net - Can A Generic Version Of A Derived Class Override A Base Method Using The Generic Type

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

Constrain A Generic Method / Extension Method To Numeric TYPEs Only?

Sep 16, 2010

Write an overload for every numeric type or if possible constrain a generic extension method to just numeric types.

View 2 Replies

See Properties Of A Generic Collection Object?

Apr 8, 2009

I have a class which extends HashSet(Of T).I am trying to evaluate some custom properties of this HashSet during execution and make decisions based on those values.

During debugging, I am pausing execution and adding a Watch on my instance of this HashSet.

The Watch only provides me with a view of the Count of the HashSet and the objects contained by the HashSet.How can I get the Watch to show me the other properties of the HashSet?

View 1 Replies

Make Several Similar Properties Call One Generic One?

Sep 14, 2011

I'm wondering if it's possible in VB.NET to make similar properties call one generic one?A sentence doesn't explain it well so here's a code example.I have a bit field defined like this:

<Flags()> _
Enum E_Operation As Integer
Upload = 1

[code]....

View 1 Replies

OrderBy Nullable Properties In A Generic List Throwing InvalidCastException?

Jun 13, 2012

I need to return an a generic list in the correct order for my project, and I'm getting InvalidCastException errors. Here is the code:

Dim lDt As List(Of Comment) = RemapCommentsForE1(so.CommentList). _
OrderBy(Function(x) x.CreateDate.Value). _
ThenBy(Function(x) x.Sequence). _

[code].....

View 2 Replies

C# - Create A Generic Method In A Class?

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

Using TrueForAll Method In Generic List?

Jun 7, 2009

I have a class myClass. MyClass has a property myName. I have a generic list myList(of myClass). I have to check if value of myName in all myClass objects in myList is same and is equal to a string myString. I have created a method:

Private Function IsMatching(ByVal objMyClass As MyClass, ByVal strMyString As String) As Boolean
If objMyClass.MyName = strMyString Then
Return True
Else
Return False
End If
End Function
Now I want to use is TrueForAll method of Generic list. How can I use it ?

If there was No second Parameter in IsMatching method, I could have simply used
myList.TrueForAll(AddressOf IsMatching)
But since there is a parameter strMyString, I dont understand how can I use IsTrueForAll method. How can I use IsTrueForAll method in this scenario.

View 2 Replies

C# - Generic Method Overloading Compilation Error In VB?

Aug 5, 2009

I have a problem with the VB.NET compiler failing to compile a class (in a separate C# assembly) which contains two overloads of a method with generic arguments. The equivalent code in C# compiles against the same assembly with no errors. Here are the two method signatures:

protected void SetValue<T>(T newValue, ref T oldValue)
protected void SetValue<T>(T? newValue, ref T? oldValue) where T : struct

Here is the code to three assemblies that demonstrate the problem. The first is the C# assembly with a Base class that implements the generic methods. The second is a C# class derived from Base and calls both overloads of SetValue correctly. The third is a VB class also derived from Base, but fails to compile with the following error message:

[Code]...

Am I doing something wrong in the VB code, or are C# & VB different when it comes to generic overload resolution? If I make the method arguments in Base non-generic then everything compiles correctly, but then I have to implement SetValue for every type that I wish to support.

View 2 Replies

Write A Generic Extension Method For Every Enumerable(Of T)?

May 30, 2012

After looking at this thread.>>

How to randomize the alphabet I have decided to make it into an extension method for a String and a List.

Note: Please see the following post if you are still using VB.Net 2002, 2003 or 2005

this code is for use with 2008 and later versions of VB.Net

String.Mix and also List.Mix I was trying to write a generic extension method for every Enumerable(Of T)

I settled on just doing it for a STRING

[Code]...

View 16 Replies

.net - 'ObjectDataSource1' Could Not Find A Non-generic Method 'getCOMDLs' That Has Parameters:

Sep 27, 2010

Getting this error message and I am not able to figure out why. Here is my code:

<asp:TextBox ID="searchParam" Width="250px" runat="server"></asp:TextBox><asp:button ID="btnSearch" runat="server" Text="Search" />
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="getCOMDLs" TypeName="NewEmployee">

[Code]...

View 1 Replies

.net - Creating A Generic Method For Converting String To Nullable Numbers

Jun 19, 2009

I have 3 similar functions, that only change based on numeric type:

<Extension()> _
Public Function ToNullableShort(ByVal str As String) As Short?
Dim intReturn As Short

[Code].....

I was trying to make a generic function out of this, but couldn't do it. How can I make a generic function that will take a specific T and make it a Nullable(of T)?

View 2 Replies

.net - Generic List Extension Method ForEach Stopped Working?

Dec 16, 2010

I have a custom list that inherits Generic.List and it has a method for deselecting all of the members named DeselectAll It has looked like this for a few weeks and has worked fine.

Public Sub DeselectAll()
MyBase.ForEach(Function(p As Publipostable) p.ModeEnvoiChoisi = Nothing)
End Sub

Today, it stopped working ?!? I reverted to an earlier version using delegates and that works fine...

Public Sub DeselectAll()
MyBase.ForEach(AddressOf DeselectModeEnvoi)
End Sub

[code]....

Edit: Stopped Working meaning it no longer sets the property p.ModeEnvoiChoisi to Nothing on each item in the list. The DeselectAll method gets called, but all the items retain their previous values...

View 1 Replies

Search A Generic List - Keep Getting:Delegate To An Instance Method Cannot Have Null 'this'?

Feb 16, 2009

I'm trying to search a generic list of 'User' business objects which has a property called 'Username': If (From u In colUsers Select u.Username Where Username.Equals(strUsername)).Count > 0 ThenI keep getting:Delegate to an instance method cannot have null 'this'.

View 16 Replies

Replace Method Not Working?

May 13, 2010

Public Class Form1
Dim x As String
'TCC ENCYRTION CODE, COPY RIGHT OF T.C co
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

[code]....

i want to change ALL the a's in the programs textbox1 to b's when the encryption button is clicked (button 1), remember when it is click it determines weather the text in textbox1.text is more then five, if so it goes onto replacing the a's if not, then it shows a error message?

View 1 Replies

Add A Replace Method To A Text Editor?

Apr 10, 2009

how to add a replace method to a text editor (notepad) to search for a word and replace it

1. say in (notepad) you type something in the textbox1-------"me"

2. then am suppose to type "me" in text box 2---and

3. click the find button and it suppose to find the text in textbox1

4. then you type in textbox3---- "us" and

5. click the replace button and it replaces "me" with "us"

View 4 Replies

Clear Replace Text Method?

Oct 15, 2009

Supose i have two TextboxOne For normal Text and Second For After Replace textif i m Type some text in textbox 1 then Textbox2 show Its Replacement Text

View 6 Replies

Using Replace Method To Change Password?

Feb 6, 2012

I am using following code to replace the passwords in my app.config. It replaces successfully but does not reload config file in the memory so datasets give error of wrong password.

Dim vrTextFind As String = "Password"
Dim vrTextReplaceWith As String = "PWD"
Dim path As String = "D:VS2008EncTestEncTestinDebugenctest.exe.config"

[code].....

View 2 Replies

Adding Replace Method To Text Editor?

Apr 9, 2009

how to add a replace method to a text editor (notepad) to search for a word and replace it in visual basic 2005

1. say in (notepad) you type something in the textbox1-------"me"

2. then am suppose to type "me" in text box 2---and

3. click the find button and it suppose to find the text in textbox1

4. then you type in textbox3---- "us" and

5. click the replace button and it replaces "me" with "us"

View 7 Replies

Refactoring A Method To Replace Sql String With The Stringbuilder Class

Nov 3, 2010

How do I refactor the method GetInvoiceNumbers to replace the SQL String concatenation with the StringBuilder class? Here is my code:

Private Function GetInvoiceNumbers() As System.Collections.Generic.List(Of Invoice) Implements InvoiceService.GetInvoiceNumbers
Dim invoiceList As New List(Of Invoice)

[Code].....

View 3 Replies

Using The Replace Method To Get A Count Of How Many Actual Replacements Were Made?

Aug 5, 2009

1. In the old VBScript, there was a compareMethod (binary or text, which with text, I could compare case) but I don't find anything like that in the new .Net Replace method. I know I can use the old way, but I'd like to use the new Replace method. I just need a choice of comparing case or not?

2. Let's say I have a long string, and I am using the Replace method - - it would be nice to get the count of instances replaced, and I'm sure that if I read line by line, I could actually get that count, but it would take to long.Is there a way, using the Replace method, to get a count of how many actual replacements were made?

View 1 Replies

Forms :: Find Replace Text From File - Fastest Method?

Nov 13, 2011

1) a text document which has content like :

uber|uber|ultra
taxi|taxi|taxi cab|cab|minicab|airport taxi|airport transfer
genitalia|genitalia|genitals

[code].....

View 1 Replies

Create Individual Properties In A Class Or Just A Method To Set The Values?

Oct 2, 2011

I am learning vb.net and I am having trouble wrapping my head around the following... I can create several properties of a custom class and get/set values or I can create a method to set them all at once. If each property is going to allow read and write should I just make a method to assign values all at once? I assume that I am missing a very important piece here. Example: I can create 2 properties:

[Code]...

View 2 Replies

Is There A Concept Of "Generic Structure" Similar To Generic Collections, Generic Classes

Dec 16, 2009

We have migrated our Vb6 application to VB.NET using a third party tool. Now we are in a process of Refactoring and introducing object oriented concepts in the application.

In VB6, we were using structures in many places. As a part of introducing object oriented programming,

1. is it a good idea of changing all Structures to Classes? or Is there a concept of "Generic Structure" similar to Generic collections, Generic classes?

2. Can some one guide me any source containing guide lines or best practices for applications that are migrated to VB.NET from VB6 and implementing object oriented programmaing.

View 3 Replies

Get Type Of Derived Generic List Class From List Item Method?

Mar 23, 2011

Public Class notifierMain
Public Class Contacts
Inherits List(Of row)
Public Sub New()

[code]....

When I debug this winforms application I get curType = "notifier.notifierMain+Contacts+row" I want to the Validate function to know it is in MyContacts. How do I do this?

View 3 Replies

When Passing An Object As An Argument To A Method, String Properties Are Populated But Integers Are Null

Jan 27, 2011

I have a class and method exposed to a client asp.net app. The class looks like

<DataContract()> _
Public Class Class1
Private v_string As String
Private v_integer As Integer

[code]....

The method is declared as

<OperationContract()> _
Function GetStuff(ByVal bar As Class1) As String

In the client code I create an instance of Class1 and set the values for v_string and v_integer, but using Wireshark to look at the xml being sent to the server only a value for v_string is being sent as part of Class1. I'm guessing this is because it considers the value of v_integer to be null/not set. Here is an example of the client code.

Dim MyService as New Service1.ServiceClient
Dim test as New Service1.Class1
test.P_integer = 1

[code]....

how different types are passed/used since Integer is a intergral type and String is a class, but can't seem to work out what to do to fix the problem.

View 4 Replies

Delete One Of Duplicated Row In Table?

Oct 8, 2011

now my code is delete all the row with Itemcode. If i only want to delete one of my duplicated Itemcode row?textbox8 is connect to Itemcode column.

Dim del2 As String
If MsgBox("History Record Delete?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Thendel2 = "Delete from Receive Where Itemcode = @Itemcode"

[code].....

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved