473,387 Members | 1,579 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Invoking case-sensitive C# methods from VB.NET

Please have a look at the code given below. The class named 'Class1' has two
methods with the same name but with different case. Now how can I invoke
these methods from VB.

using System;

namespace ClassLibrary1
{
/// <summary>
/// Summary description for Class1.
/// </summary>
public class Class1
{
public Class1()
{
//
// TODO: Add constructor logic here
//
}

public string hello()
{
return "Small h";
}

public string Hello()
{
return "Capital H";
}
}
}
Nov 16 '05 #1
2 1689
Nelson P. Varghese wrote:
Please have a look at the code given below. The class named 'Class1'
has two methods with the same name but with different case. Now how
can I invoke these methods from VB.


This code is not CLS compliant, so the answer is you can't. Marking the
assembly [assembly: CLSCompliant(true)] should produce a warning (error?).

Cheers,
--
Joerg Jooss
www.joergjooss.de
ne**@joergjooss.de
Nov 16 '05 #2
> Please have a look at the code given below. The class named 'Class1' has
two
methods with the same name but with different case. Now how can I invoke
these methods from VB.

You must use reflection to separate the camel cased method from the Pascal
cased method.

Dim myClass As New Class1
Dim camel, pascal As String
camel = myClass .GetType.InvokeMember("hello", _
System.Reflection.BindingFlags.Instance Or _
BindingFlags.Public Or BindingFlags.InvokeMethod, _
Nothing, Class1, Nothing, Nothing, Nothing, Nothing)

pascal = myClass .GetType.InvokeMember("Hello", _
System.Reflection.BindingFlags.Instance Or _
BindingFlags.Public Or BindingFlags.InvokeMethod, _
Nothing, Class1, Nothing, Nothing, Nothing, Nothing)

Anders Norås
http://dotnetjunkies.com/weblog/anoras/
Nov 16 '05 #3

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

Similar topics

0
by: Prasad | last post by:
We are invoking a SQL DTS component (lets call it Comp1) built by us in another component (Comp2).Comp1 was built by creating the DTS package using the SQL DTS wizard and then saving it as a VB...
1
by: Alex Vinokur | last post by:
Hi, I have a problem with invoking an instance before main() when using memory allocation for static member. Is the program below valid? =========================================== Windows...
3
by: bbxrider | last post by:
running win2k adv server/ iis5.0 trying to setup on my web page where browsers can download a file, an .xls so been trying to figure out with a download 'link' what invokes the standard ms file...
5
by: Philip | last post by:
I have a C# program invoking a MC++ method. One of the output parameters is an "int".... defined as "int iretval". In the C# program I want to pass the parameter as either "ref iretval" or "out...
4
by: Joanna Carter \(TeamB\) | last post by:
I am trying to invoke an event using reflection. ////////////////////// public class Test { public event EventHandler NameChanged; public void CallEvent() {
5
by: RJN | last post by:
Hi I'm invoking the excel object from ASP.Net application. My development machine is Windows 2000 and MS Office is installed on my m/c. I have added reference to the Excel COM object, I have...
4
by: rjn | last post by:
Hi I'm invoking the excel object from ASP.Net application. My development machine is Windows 2000 and MS Office is installed on my m/c. I have added reference to the Excel COM object, I have...
0
by: Haxan | last post by:
Hi, I have an unmanaged application that converts a function pointer to a delegate and then pass this as a parameter(delegate) to a managed function which then invokes it. Currently Im able to...
0
by: balaji krishna | last post by:
Hi, I need to handle the return set from COBOL stored procedure from my invoking Java program. I do not know, how many rows the stored proc SQL fetches.I have declared the cursor in that proc, but i...
2
by: =?Utf-8?B?SmltIE93ZW4=?= | last post by:
Hi John, Hopefully this post will find its way back to you - or perhaps be answered by someone else. As I mentioned in my last post on the earlier portion of this thread, changing the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...

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.