473,785 Members | 3,349 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# to VB.NET conversion (Generics confusion)

Hi

I'm trying to call a C# Method from with VB.NET and am having all
sorts of troubles as I'm new to Generics. The C# method (which I
didn't develop) is as follows:

/// <summary>
/// Implementation of <c>Register(Act ion&lt;T&gt; handler)</c>
method of <c>ISubscriptio nService&lt;T&g t;</c>
/// interface. Subscribes an action to be performed when a
publishing event occures.
/// Implements subscription functionality of the Publish/
Subscribe pattern.
/// The method also processes the filter custom attributes
which allows a user to define filters
/// externally.
/// </summary>
/// <param name="handler"> Represents the method that performs
an action on the specified object
/// when a publishing event occures.</param>
public virtual void Register(Action <Thandler)
{

In my VB.NET code I need to call this Register method and pass to it
the name of the Routine I want called when an event is raised. The C#
examples I've been provided are as follows:

To Register your event routine:
eventBrokerServ ice.Register(th is.OnConfEventO bjectsRead);

Declaration of the event rouine:
[MessageIdFilter (EventError.Mes sageId, ProtocolName = "ConfServer ",
SdkName = "Configuration" )]
private void OnConfEventErro r(IMessage theMessage)
{

Can someone help me convert the above statements to register an event
routine and declare an event routine to the equivalent VB.NET syntax.
I'm real stuck!

Thanks
Jun 27 '08 #1
1 1001
"Peter" <pe*****@circ le-consulting.co.n zschrieb:
I'm trying to call a C# Method from with VB.NET and am having all
sorts of troubles as I'm new to Generics. The C# method (which I
didn't develop) is as follows:
[...]
public virtual void Register(Action <Thandler)
{

In my VB.NET code I need to call this Register method and pass to it
the name of the Routine I want called when an event is raised. The C#
examples I've been provided are as follows:

To Register your event routine:
eventBrokerServ ice.Register(th is.OnConfEventO bjectsRead);
='<...>.Registe r(New Action(Of <type>)(Address Of
OnConfEventObje ctsRead))'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3038
by: Vijai Kalyan | last post by:
Hello, I have come back to C++ after a couple of years with Java so I am quite rusty and this question may seem poor: My platform is Windows XP with MSVC 7.1. I have a class with a templatized conversion operator defined as follows:
14
9330
by: junky_fellow | last post by:
Can anybody please explain this: When a value with integer type is converted to another integer type other than _Bool, if the new type is unsigned, the value is converted by repeatedly adding or subtracting one more than the maximum value that can be represented in the new type until the value is in the range of the new type.
2
2747
by: Wiktor Zychla | last post by:
I've read several documents about upcoming C# generics and I still cannot understand one thing. Would it be valid to write a code like this: class SomeClass { public void AMethod<T>(T a, T b) { T c = a + b; // ?
14
2228
by: Richard G. Riley | last post by:
Would it be wrong to use "implicit casting" instead of the standards "implicit conversion" when talking about implicit conversions between certain data types. The standard mentions "explicit conversion" for a cast operation
9
5986
by: sloan | last post by:
I'm not the sharpest knife in the drawer, but not a dummy either. I'm looking for a good book which goes over Generics in great detail. and to have as a reference book on my shelf. Personal Experience Only, Please. ...
10
13642
by: =?Utf-8?B?RWxlbmE=?= | last post by:
I am surprised to discover that c# automatically converts an integer to a string when concatenating with the "+" operator. I thought c# was supposed to be very strict about types. Doesn't it seem like c# is breaking its own rules? This works: int b = 32; string a = "ABC " + b; Result: a = "ABC 32"
2
1282
by: joseph_gallagher | last post by:
Hi, I've been playing with generics and I was wondering if anyone could tell me why the following doesnt work, and if there is another way to do it public class A<Twhere T : B, new() { public B Get() { B b = new B(); b.X = this;
13
1818
by: =?Utf-8?B?RGF2ZSBXZWVkZW4=?= | last post by:
Hi all, I'm having trouble with a project that I've distilled down to the following code. Unfortunately it won't compile and gives the following error (caused by the call to GetHorses() in HorseFarm's GetAnimals() method): Cannot implicitly convert type 'MyCollection<Horse>' to 'MyCollection<IAnimal>'
9
6350
by: =?Utf-8?B?RmxhdmVsbGUgQmFsbGVt?= | last post by:
Apparently the Java Conversion tool that used to be in Visual Studio 2005 is no longer supported in Visual Studio 2008. Anyone have any suggestions on how to convert a Java program to C# in Visual Studio 2008?
0
10319
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10087
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9947
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8971
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7496
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5380
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4046
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.