Extends in C# or VB.NET?

  • Thread starter Thread starter tascien
  • Start date Start date
T

tascien

In java, you can do:

public class MyJButton extends JButton{
public MyJButton(){
}
}

then you can use this custom button as if it was a JButton...

Applet.add(new MyJButton());
same as
Applet.add(new JButton());

is it possible in C# or VB.net?

Question 2:

In vb.net i can do:

Dim ohttp As Object = Server.CreateObject("MSXML2.ServerXMLHTTP")
ohttp.Open ("GET","http://www.google.ca",false)
ohttp.Send()

But in C#, it says that Generic Object does not have 'Open' method?
what can i use?
 
In C#:
public class MyJButton: JButton
In VB:
Public Class MyJButton
Inherits JButton
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB.NET to C# Converter
Instant VB: C# to VB.NET Converter
Instant J#: VB.NET to J# Converter
Clear VB: Cleans up outdated VB.NET code
 
In answer to question 2:

C# doesn't accept (I think it's called) late binding. So the object you
declare must expose the methods you want. I'm not familiar with
ServerXMLHTTP, but you'd have to do something like:

Object ohttp = Server.CreateObject("MSXML2.ServerXMLHTTP");
ServerXMLHTTP http = (ServerXMLHTTP)ohttp; // explicit cast
http.Send();
....

See also
help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/dnaspp/html/aspnetmigrissues.htm,
which has this specific example under the heading "OnStartPage and OnEndPage
Methods", about half way down the page. (Note: that this link will only work
if you have the documentation on your machine. Maybe someone has the actual
URL at microsoft?)
 
Back
Top