473,397 Members | 2,033 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,397 software developers and data experts.

Problem extending Object

Hello,

I'm trying to add an extension to Object using VB. It shows up in the
intellisense for other kinds of reference objects, but not if the variable
is simply declared as Object.

It works without problems when I use C#, but not from within VB...any ideas
as to what is going on?

Imports System.Runtime.CompilerServices

Module StringUtils

<System.Runtime.CompilerServices.Extension()_
Public Function eMyE(ByVal o As System.Object, _
ByVal sep As Char) As String
Return "1"
End Function
<System.Runtime.CompilerServices.Extension()_
Public Function eMyE(ByVal o As System.Object) As String
Return o.eMyE(" ")
End Function
End Module
Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As _
System.EventArgs) Handles Button1.Click
Dim b As String ' sender.eMyE doesn't show up in intellisense
End Sub
End Class
## and here it is in C#

using System;
using System.Runtime.CompilerServices;
using System.Windows.Forms;

namespace TestExtensionsC
{
public static class StringUtils
{
public static string eMyE(this object str, char sep)
{
return "1";
}

public static string eMyE(this object str)
{ return str.eMyE(' '); }
}

public partial class Form1 : Form
{

public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
string b = sender.eMyE();
}
}
}

--
J. Moreno
Aug 26 '08 #1
0 747

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

Similar topics

4
by: Alicia Haumann | last post by:
I accidentally sent this to webmaster@python.org, so this could be a duplicate if "webmaster" forwards it to this list. :{ Hi, there. Thanks for any help that can be offered. I've been...
3
by: Flip | last post by:
I'm looking at the O'Reilly Programming C# book and I have a question about extending and combining interfaces syntax. It just looks a bit odd to me, the two syntaxes look identical, but how does...
7
by: A Traveler | last post by:
Hello all, i was just curious if anyone whos been playing with VS2005 could tell me... In javascript (and java??) you can alter the prototypes for an object in your project. I dont remember...
4
by: Ian Richardson | last post by:
Hi, The function I've put together below is a rough idea to extend a SELECT list, starting from: <body> <form name="bambam"> <select id="fred"> <option value="1">1</option> <option...
2
dream party
by: dream party | last post by:
Inserting a Flash (SWF, FLV) file into HTML web page is already an old and familiar thing to all of us. It is a rather non-flexible thing that just to edit some options in the template. However, I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...
0
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...
0
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...
0
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...
0
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,...

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.