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. CompilerService s
Module StringUtils
<System.Runtime .CompilerServic es.Extension()_
Public Function eMyE(ByVal o As System.Object, _
ByVal sep As Char) As String
Return "1"
End Function
<System.Runtime .CompilerServic es.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(B yVal sender As System.Object, _
ByVal e As _
System.EventArg s) 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. CompilerService s;
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()
{
InitializeCompo nent();
}
private void button1_Click(o bject sender, EventArgs e)
{
string b = sender.eMyE();
}
}
}
--
J. Moreno
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. CompilerService s
Module StringUtils
<System.Runtime .CompilerServic es.Extension()_
Public Function eMyE(ByVal o As System.Object, _
ByVal sep As Char) As String
Return "1"
End Function
<System.Runtime .CompilerServic es.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(B yVal sender As System.Object, _
ByVal e As _
System.EventArg s) 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. CompilerService s;
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()
{
InitializeCompo nent();
}
private void button1_Click(o bject sender, EventArgs e)
{
string b = sender.eMyE();
}
}
}
--
J. Moreno